Mac

January 29, 2009

How to use self-signed HTTPS / SSL certificates using gsoap?

Filed under: Uncategorized — mac @ 10:42 am

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.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google]

Powered by WordPress