我有WCF web服务,需要使用SSL/TLS协议进行保护。另一方面,我有使用C++ web服务的gSOAP库客户端。已经只有服务器需要有证书。现在我的任务是强制客户端拥有证书。我以前为客户端实现的如下所示:
soap_ssl_init();
int soapResult = soap_ssl_client_context(soapPtr, SOAP_SSL_NO_AUTHENTICATION, "client.pem", NULL,
NULL, "cacert.pem", NULL);
if (soapResult)
{
soap_print_fault(soapPtr, stderr);
throw new ClientLogException("Can not use ssl for comminucations!");
}
else
{
}
struct soap mySoap = *soapPtr;
WSHttpBinding_USCOREILogServicesProxy proxy(mySoap);
input.request = &request;
int callCode = proxy.CallWebService(WEB_SERVICE_ADDRESS, NULL, &input, response);
if (callCode != 0)
{
cout << "Web service call code: " + callCode << endl;
throw new ClientLogException("Error in calling web service with call code: " + callCode);
} 这是我从gSOAP文档做的。它可以很好地工作,只有服务器需要有证书。我使用WireShark查看通信,连接是完全加密的。
现在,为了强制客户端使用证书,我将使用在WCF上启用X.509证书的九个简单步骤文章。但是本文使用了一个C# WCF客户机。我必须在我的gSOAP C++客户机中实现客户端配置。在调用soap_ssl_client_context和第三个参数时,我可以在上面的代码中添加客户端证书。
我这里有两个问题:
我不知道当服务器使用WCF和客户端使用gSOAP时,客户端和服务器都有证书和通信是可能的吗?
2-在CodeProject的文章中,似乎web服务调用使用的是、http、,我想知道通信中没有加密。
最后,如果有人有更好的解决方案,或推荐其他工具,将受到欢迎。
发布于 2016-02-27 17:10:21
如果使用-DWITH_OPENSSL编译并针对OpenSSL库进行链接,则HTTPS可以使用gsoap进行开箱即用。开箱即用的默认设置将使用https://加密消息,但这并不强制身份验证,因为您需要首先向soap_ssl_client_context()注册服务器证书,正如您指出的那样。
为了对服务器和客户端进行身份验证,gsoap手册建议如下:
int soapResult = soap_ssl_client_context(soapPtr,
SOAP_SSL_DEFAULT, // requires server to authenticate
"client.pem", // client cert (+public key) to authenticate to server
"password", // you need this when client.pem is encrypted
NULL, // capath to certs, when used
"cacert.pem", // should contain the server cert
NULL);此外,您可能需要将PEM到CER (或其他方式)转换为windows。
https://stackoverflow.com/questions/34067399
复制相似问题