I've got a little private webserver where I have several virtualhosts. I know that it's impossible to assign a certificate to each individual virtualhost, because the server finds out which virtualhost was requested only AFTER the SSL connection has been established. But is it possible to have a single SSL certificate which lists several domains? Or at least a wildcard domain, like *.example.com. If yes, what Linux commands do I have to write to make such a self-signed certificate?
Added: To clarify - I have just one IP address for all the virtual hosts.
The following should work for you:
Result:
If you want request instead of self-signed just replace -x509 with -new and -extensions with -reqexts.
Update
Subject Alternative Name can be specified directly in command line with the recent versions of openssl:
See also https://security.stackexchange.com/questions/74345/provide-subjectaltname-to-openssl-directly-on-the-command-line/183973#183973
Create a certificate with domain.com as the CN and *.domain.com in the subjectAltName:dNSName names field - that works.
In
openssl
, add this to the extensions:To expand on AlberT's answer:
http://blog.loftninjas.org/2008/11/11/configuring-ssl-requests-with-subjectaltname-with-openssl/
You don't have to use wildcard domains. You can just list all hostnames you need as subject alt names and it should work on all major browsers.
First of all - you can assign a certificate for each individual virtual host - the key is to make different private (and external/public, if you want to make it world accessible) ip address for each virtualhost.
But then yes - alternatively, you can assign a wildcard certificate if your virtual hosts is simply *.example.com.
For the command - there are many results from google - i'll just put an example from here:
http://www.justinsamuel.com/2006/03/11/howto-create-a-self-signed-wildcard-ssl-certificate/
And make sure you enter *.example.com for the Common Name.