c++ - gSOAP - How to use SSL and self-signed certificate -


i need connect cross-platform program soap web service. have compiled gsoap tools wsdl2h , soapcpp2 , these tools have generated source code files from .wsdl file. have putted in stdsoap2.h define "#define with_openssl" , in way ssl used. problem when call service call return error 30 means ssl error don't know problem. know server send self-signed certificate because testing environment. indeed error message related printed. output is:

creating soap objects ... calling soap httpaccessservice: ssl verify error or warning certificate @ depth 0: self signed certificate certificate issuer /c=it/st=milan/l=milan/o=company/ou=company/cn=company.it certificate subject /c=it/st=milan/l=milan/o=company/ou=company/cn=company.it soap error 30 

the function use call service this:

void gsoaptesting::runtest() { int result = 0; size_t requestsize; size_t responsesize;

char endpoint[1024]; char buffer[8192];  string soapaction; struct soap *soap_container;   applicationconfigurationservicesoapbindingproxy proxy1;  _ns1__httpaccessservice *httpaccessservice; _ns1__httpaccessserviceresponse *httpaccessserviceresponse;  printf("creating soap objects ...\n"); soap_container = soap_new(); //soap_container->mode    httpaccessservice = (_ns1__httpaccessservice *) soap_instantiate(soap_container , soap_type___ns1__httpaccessservice , "" , "" , &requestsize); httpaccessserviceresponse = (_ns1__httpaccessserviceresponse *) soap_instantiate(soap_container , soap_type___ns1__httpaccessservice , "" , "" , &responsesize);  soap_ssl_init(); /* init openssl (just once) */  if(soap_ssl_client_context(soap_container , soap_ssl_default , null, null, null, null, null      ) != soap_ok) {    printf("soap ssl initialization failure\n");      soap_print_fault(soap_container , stderr);    return ; }    printf("calling soap httpaccessservice:\n");  soapaction.clear(); soapaction.append(soap_namespace_of_ns1); soapaction.append("/"); soapaction.append("httpaccessservice");      result = proxy1.httpaccessservice("https://xxx.xxx.xxx.xxx:xxxx" , null , httpaccessservice , httpaccessserviceresponse);  if(result == soap_ok) {     printf("soap ok\n");                          } else {     printf("soap error %d\n" , result);      if(soap_check_state(soap_container) ) printf("error: request soap struct not initialized\n");      if(httpaccessservice->soap == null)     {         printf("error: null request soap struct\n");            return;                               }      if(httpaccessservice->soap->endpoint == null) printf("error: empty request endpoint\n");      soap_stream_fault(soap_container , std::cout);         }     

}

any appreciated.

the problem related certificate not trusted because self-signed. if comment these lines in stdsoap2.cpp...

if (!ok) { soap_set_sender_error(soap, "ssl/tls error", "ssl/tls certificate host name mismatch in tcp_connect()", soap_ssl_error);   soap->fclosesocket(soap, sk);   return soap_invalid_socket; } 

...the certificate accepted if issued unknown authority.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -