Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use SSL in C++ gSOAP generated classes

Tags:

c++

https

ssl

gsoap

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_sEc19.20). in particular, i have compulation error on soap_ssl_init(); function. i've looked /usr/lib/libgsoap* files and found ligsoapssl++.a file and linked against it. this error has gone, but i get error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed. that's mean i need to call soap_ssl_client_context func, but there isn't in C++ generated classes. What should i do?

UPD: i've solved this trouble by myself. but it's quirky, very quirky way. gSOAP generates C++ classes inherited from struct soap, it contains following attrs:

BIO *bio;
SSL *ssl;
SSL_CTX *ctx;
unsigned short ssl_flags;
const char *keyfile;
const char *password;
const char *dhfile;
const char *cafile;
const char *capath;
const char *crlfile;
const char *randfile;
SSL_SESSION *session;

so we can setup necessary attrs (flags, params) as in OpenSSL library by ourselves. In simple case it's enough to call soap_ssl_init() once and set ssl_flags = SOAP_SSL_NO_AUTHENTICATION. it works for me. if anyone knows better way i'll glad to see.

like image 849
milo Avatar asked Jun 11 '11 12:06

milo


1 Answers

This works for me:

soap_ssl_client_context(m_proxy.soap, SOAP_SSL_NO_AUTHENTICATION, NULL, NULL, NULL, NULL, NULL);

where m_proxy is an instance of the client proxy generated using gSOAP:

wsdl2h.exe -o MyWebservice.h ..\MyWebservice.wsdl
soapcpp2.exe -IC:\gsoap-2.8\gsoap\import -j MyWebservice.h -C -1 -SL
like image 133
uceumern Avatar answered Oct 26 '22 00:10

uceumern