Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Build your own HTTPS server with Delphi – Open SSL Example

Build your own HTTPS server with Delphi – Open SSL Example

Assuming that you know how to make a web server with TidHttpServer, but now you need to put your server in HTTPS, so to do that you need to add to your application the TIdServerIOHandlerSSLOpenSSL and set it as the IOHandler of your TidHTTpServer.

IMG IOHANDLERIOHandler

Now you need a valid and unique certificate, to make some tests you can use an Open SSL certificate, to have it you can write this command, and compile all question that openssl do, don’t forget the password you specified:

this certificate is self signed, so when you use a browser to view your server pages the browser make a security information to you. We normally buy a Wildcard certificate for our server on Netsons.com and create a private key with apache.

After that we put the key and the certificate in the same file:

Now we have “mycert.pem” file, and we need to put that in the application folder, and we can configure the TIdServerIOHandlerSSLOpenSSL to manager the certificate like this:

SSLConf

after this you need to manage two events on the TIdServerIOHandlerSSLOpenSSL like this:

To run the application, for example on a Win32 system you need to add the openSSL libraries to you appication folder:

ElencoDll

to obtain (download) the newest release of openssl library you can visit : https://indy.fulgan.com/SSL/

At the end when you buy the certificate for the application the result is:

theend

 

On newer Delphi version you need to implement “OnQuerySSLPort” method to allow SSL connections on port different to 443 like the next sample code: