Ssl – How does a web server know which key pair to use for SSL decryption

httpssslweb-server

It is my understanding that when Apache receives a request to one of the TCP ports it is listening on (e.g. 80, 443), it will decide which host is being requested by looking at the HTTP header Host. The server will then know which virtual host it should redirect the request to.

But how does it work for HTTP over SSL/TLS? Since the whole HTTP request is being encrypted (at least that's what I believe I have read somewhere), the header information can only be read after the server has decrypted the data. But in order to decrypt, it needs to know which key pair to use as you can have multiple SSL certificates installed on a web server.

So how does the server know which key it needs for decryption?


My guess:

I could imagine that the TLS handshake provides the necessary information.


Regarding the "possible duplicate" flag:

While I agree that the answers to both the linked question and my own are similar, I must say the question is different. It is out of question whether or how hosting multiple sites with independet SSL certificates is possible. Instead my question addresses the underlying technical aspect.

Best Answer

Originally, the web server didn't know. This was the reason that you needed a separate IP address for every SSL vhost you wanted to host on the server. This way, the server knew that when a connection came in on IP X, he needed to use the configuration (including certificates) for the associated vhost.

This changed with Server Name Indication, a TLS extension that indeed allows a client to indicate the required hostname in the handshaking process. This extension is used in all modern OS, but old browsers or servers don't support it, so if you expect clients to still use IE 6 on WinXP, you would be out of luck.

Related Topic