How to implement Server Name Indication(SNI) on OpenSSL in C or C++?
Are there any real world examples available?
How to implement Server Name Indication(SNI) on OpenSSL in C or C++?
Are there any real world examples available?
Copyright © 2021 Jogjafile Inc.
On the client side, you use
SSL_set_tlsext_host_name(ssl, servername)before initiating the SSL connection.On the server side, it's a little more complicated:
SSL_CTX()for each different certificate;SSL_CTX()usingSSL_CTX_set_tlsext_servername_callback();SSL_get_servername(ssl, TLSEXT_NAMETYPE_host_name). Figure out the rightSSL_CTXto go with that host name, then switch theSSLobject to thatSSL_CTXwithSSL_set_SSL_CTX().The
s_client.cands_server.cfiles in theapps/directory of the OpenSSL source distribution implement this functionality, so they're a good resource to see how it should be done.