Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Possible Duplicate:
Multiple SSL domains on the same IP address and same port?

Lets say I have two sites that are currently configured on the same box in VirtualHost blocks <VirtualHost 192.168.1.1:80>. How do I configure Apache so that I can put both sites under two different SSL certs?

http://a.com => https://b.com
http://b.com => https://a.com

An answer containing a link to a good tutorial on setting this up would be fantastic.

Thanks.

share|improve this question

migrated from stackoverflow.com Oct 29 '11 at 4:43

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Shane Madden, Ward, RobM, Iain, MikeyB Oct 29 '11 at 14:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

3 Answers

up vote 3 down vote accepted

You don't. At least not yet, not on live web servers.

SSL negotiation, key exchange, sending of the certificate and all that, is done before the request is transmitted -- that is, before the server even knows which site the client is trying to connect to. The site has to serve the right certificate, though, or it will get flagged by the browser as fraudulent.

So, SSL requires one certificate per IP/port combo. No way around that, short of changing SSL itself. If you want multiple SSL sites with different certs on the same port, you'll need different IPs for each. (Although SSL sites are typically on port 443, for reference...)

Any way you might find around this will require that both sites share a certificate. And as far as SAN certs go, they seem to run between 2x and 4x as much as regular SSL certs -- and probably require lots of validation. If you don't own both domains, good luck getting one cert for them both.

If you want to try this, you may want to look at http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI -- it explains a bit on how to set up TLS virtual hosts in Apache under one IP, with different certificates for each one. But note i said TLS, not SSL -- there's no way under SSL, and it's not guaranteed to work even with TLS, as the capability requires TLS support (and an optional extension thereto) enabled in both client and server. It being optional, clients don't have to provide the server name during handshaking (and XP and many mobile browsers are particularly prone not to), making whatever sites share that IP inaccessible to them. If this is going to be for sites you intend for people to actually look at, IMO it's not an option.

share|improve this answer
2  
You don't? Well, I do. ietf.org/rfc/rfc4366.txt –  Shane Madden Oct 29 '11 at 7:16
    
@Shane: Then you're not running a web server, you're playing around. Note (1) i was talking about SSL, which is by far more commonly used and supported and understood than TLS. (2) RFC 4366 describes extensions to TLS, that are not at all mandatory. Even among browsers and OSes that support TLS, they might not tell the server about the intended domain name. You rely on clients to provide that info, and at least one (probably all) of your sites will be totally inaccessible to a number of browsers. –  cHao Oct 29 '11 at 12:53
    
You stated that there was no way around it "short of reinventing SSL/TLS" - which is not the case. To your points: 1) The vast majority of client browsers in the world do support TLS 1.0 - which has been the subject of much hand-wringing with the recent CBC encryption exploit. 2) Every major browser supports SNI, with the major caveat that the Windows XP crypto library does not. While I agree that the lack of support for Windows XP clients is a deal-killer for most web servers, that will not be the case in a year or two - and those who don't have XP clients can do it now. –  Shane Madden Oct 29 '11 at 14:39
    
@Shane: Good points. I've softened and clarified a bit. But still, i can't bring myself to recommend it for a public web server. :P –  cHao Oct 29 '11 at 15:05
    
Fair enough, I agree with you on that. 2014 and XP's end of life are just around the corner! Or so I keep telling myself. ;) –  Shane Madden Oct 29 '11 at 18:49
add comment

You can do it with some mod_rewrite magic. It's a hack, but apparently works:

http://blog.revolunet.com/index.php/reseau/administration/hosting-multiple-ssl-vhosts-on-a-single-ipportcertificate-with-apache2

share|improve this answer
1  
For some value of "works". Both sites may have a certificate, but they won't get a valid cert. Unless of course you went and paid $400 for a wildcard or multi domain cert. –  cHao Oct 29 '11 at 4:20
add comment

This can be done! The trick is to actually have a single SSL cert that has Subject Alternative Name DNS entries for all the extra domain names you want to serve from the same server. Assuming you're buying your SSL certificate from one of the major certification authorities, you can probably expect to pay some extra for that type of "multi domain" certificate, and the instructions for adding those Subject Alternative Name entries varies by vendor.

A web search for "Subject Alternative Name" or "Multi Domain Certificate" and your certification authority's name should get you the instructions you're looking for.

share|improve this answer
    
But be aware that while nearly all desktop browsers support SAN, there are still a significant number of mobile phone browsers that don't. digicert.com/subject-alternative-name-compatibility.htm –  Mike Scott Oct 29 '11 at 4:57
    
Are "Older smart phones running Symbian OS" and "Older Palm Treos" really "a significant number of mobile phone browsers"? Granted, it's something to watch out for, but I think the significance of the number of affected clients is debatable. –  dkeen Oct 30 '11 at 18:06
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.