使用WCF和gSOAP向服务器和客户端添加证书
Add certificate to both server and client using WCF and gSOAP
我有WCF web服务,需要使用SSL/TLS协议进行安全保护。另一方面,我有使用gSOAP库使用WCF web服务的C++客户端。已经只有服务器需要证书。现在我的任务是强制客户端拥有证书。我之前为客户端实现的是这样的:
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
和第三个参数时,我可以在上面的代码中添加客户端证书。
我有两个问题:
1-我不知道当服务器使用WCF而客户端使用gSOAP时,是否可能调用客户端和服务器都有证书和通信安全的web服务。
2-在CodeProject的文章中,web服务调用似乎使用http,我想知道通信中没有加密。
最后如果有人有更好的解决方案,或者推荐其他工具都会受到欢迎。
HTTPS在gsoap中开箱即用,如果您使用-DWITH_OPENSSL
进行编译并针对OpenSSL库进行链接。开箱即用的默认设置将使用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);
此外,对于windows,您可能需要将PEM转换为CER(或其他方式)。
相关文章:
- "unknown ca"自生成的 CA、证书和客户端/服务器
- 如何将函数集合传递给客户端类,以便将它们当作客户端类本身的成员使用
- 使用调试/崩溃报告将应用程序部署到客户端
- 如何在本地机器上运行c++和javascript客户端代码(hackerbank风格)
- 如何通过套接字将文本文件的内容从服务器发送到客户端
- 从服务器传输到客户端的消息不会出现
- OpenSSL TLS服务器-使用客户端证书白名单
- 当服务中的事件被触发时,如何将响应从服务发送回客户端?
- 我可以与 python 服务器而不是 c++ 客户端建立 tcp/ip 套接字吗?
- 提升 Asio TCP 服务器 处理多个客户端
- boost::asio UDP 广播客户端仅接收"fast"数据包
- 如何绑定 C++ gRPC 客户端的网络接口
- C++套接字客户端到 Python 服务器未创建连接
- 用于解析 win64 堆栈跟踪的命令行客户端(可以访问符号服务器)
- 将相机数据从服务器实时流式传输到客户端
- 如何将 Firebase 与基于 Linux 的客户端应用配合使用,以便与服务器进行双向消息通信
- GRPC C++ TLS 客户端 grpc::SslCredentials() 方法不返回
- 是否可以添加多个服务器地址?(Asio,客户端>服务器)
- 向我的 TCP 客户端/服务器应用添加加密层的最直接方法是什么?
- 使用WCF和gSOAP向服务器和客户端添加证书