-1

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.

3 Answers3

3

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.

cHao
  • 463
  • 1
  • 3
  • 10
  • 2
    You don't? Well, I do. http://www.ietf.org/rfc/rfc4366.txt – Shane Madden Oct 29 '11 at 07: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
-1

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

Marc B
  • 290
  • 1
  • 3
  • 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 04:20
-1

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.

dkeen
  • 1
  • But be aware that while nearly all desktop browsers support SAN, there are still a significant number of mobile phone browsers that don't. http://www.digicert.com/subject-alternative-name-compatibility.htm – Mike Scott Oct 29 '11 at 04: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