how to use SSL in C++ gSOAP generated classes

前端 未结 4 2119
眼角桃花
眼角桃花 2021-02-15 13:31

i need to use gsoap library in C++ and i need to use https. documentation says how to work with HTTPS in C, but not in C++ (http://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc1

4条回答
  •  既然无缘
    2021-02-15 13:55

    I have experienced the same problem today. I was using Ubuntu 14.04 on VirtualBox and Gsoap 2.8.21.

    I generated C++ proxy classes with command:

    soapcpp2 -1 -I/opt/libraries/gsoap/build/2.8.21/share/gsoap/import -C -j temporary.h 
    

    At a first place, I used the aforementioned solution and set ssl_flags to SOAP_SSL_NO_AUTHENTICATION. Thanks to this error disappeared.

    Moreover I observed that while changing flags to SOAP_TLSv1, it also makes the errors disappear. The flag that causes headaches was SOAP_SSL_REQUIRE_SERVER_AUTHENTICATION which is by default set inside SOAP_SSL_DEFAULT flag.

    Everything seemed fine, until I recompiled gsoap from source with flag --enable-debug. Soon after I started to see something like:

    SSL verify error or warning with certificate at depth 1: unable to get local issuer certificate

    The best solution I found so far is to download the cacerts.pem file from gsoap site https://www.cs.fsu.edu/~engelen/cacerts.pem.zip and unzip them next to your executable.

    And of course in your code you should have something similar to:

    soap *soap = soap_new();
    soap->ssl_flags = SOAP_SSL_DEFAULT;
    
    soap_register_plugin(soap, soap_wsse);
    soap->cafile = "cacerts.pem";
    

    Then all the warning and error messages disappear.

提交回复
热议问题