How to use self-signed HTTPS / SSL certificates using gsoap?
gsoap is a common framework used in C / C++ to write SOAP clients (among other things).
It took me quite some time to figure out how to enable gsoap to use self-signed https certificates. It’s actually a simple 2-step process:
Enable SSL
Simply add -DWITH_OPENSSL to your compile options
Tell soap NOT to check the certificate
gsoap generates a set of classes which inherit from the core soap class. In my example my own class is called NotificationBindingProxy
For each of those classes you need to initialize the ssl client context with the right flags:
NotificationBindingProxy nbp;
if (
soap_ssl_client_context(&nbp, SOAP_SSL_SKIP_HOST_CHECK, NULL, NULL, NULL, NULL, NULL))
{
soap_print_fault(&nbp, stderr);
exit(1);
}
This way you do NOT verify the identity of the server, but your communication is still encrypted.