I'm building an HTTPS proxy in node
. Basically I'm allowing people to set a DNS CNAME alias to my proxy machine (which has a wildcard DNS setupped), and import their SSL certificate into my application (like AWS Elastic Load Balancer does) so that their CNAME hostname is properly protected and recognized by the client on every request.
Now I'm working on the proxy side, and I'm trying to find a way to load the right certificate dynamically before the SSL handshake with the client. The workflow is:
- A new request is received by the server
- Get the hostname requested by the client (that is the DNS CNAME alias set by the user)
- Load the right certificate belonging to that hostname
- Use the loaded certificate in the current request (need help here)
- Handshake (with the loaded certificate - which varies from request to request)
Is there a way to do that?