我想使用gSOAP连接HTTPS Web服务,我发现如何使用gSOAP首先调用soap_ssl_client_context(),我从here找到的例子是
if (soap_ssl_client_context(
&soap, //1
SOAP_SSL_DEFAULT, //2
"client.pem", //3 /* keyfile: required only when client must authenticate to server (see SSL docs on how to obtain this file) */
"password", //4 /* password to read the key file (not used with GNUTLS) */
"cacerts.pem", //5 /* cacert file to store trusted certificates (needed to verify server) */
NULL, //6 /* capath to directory with trusted certificates */
NULL //7 /* if randfile!=NULL: use a file with random data to seed randomness */
))
{
soap_print_fault(&soap, stderr);
exit(1);
}
但我找不到任何有关参数细节的文档。我的问题是:
----------------更新---------------
关于#1问题,我检查了gSoap和OpenSSL中的源代码,发现它使用PEM(x.509)函数加载certfile。
soap_init()
{
//...
soap->fsslauth = ssl_auth_init;
//...
}
soap_ssl_client_context()
{
//...
soap->cafile = cafile;
//...
return soap->fsslauth(soap);
}
ssl_auth_init()
{
//...
SSL_CTX_set_client_CA_list(soap->ctx, SSL_load_client_CA_file(soap->cafile));
//...
}
SSL_load_client_CA_file
{
//...
if (PEM_read_bio_X509(in,&x,NULL,NULL) == NULL)
//...
}
非常感谢,
Aidy
参数3和5支持通用PEM格式。要将CRT转换为PEM,请参阅:how-to-convert-crt-to-pem,您可以使用openssl命令将DER转换为PEM。参数6是证书(PEM格式)所在位置的目录路径。该选项很慢,因此优选使用cacerts.pem(或特定的cacert.pem)的非NULL参数5。