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.

I currently have a SSL certificate which is registered for https://www.domain.com. I didn't register https://domain.com and I don't have money to do that.

Since the SSL exchange is done before the actual site is loaded, I can't simple put a redirect in .htacess without the client getting a SSL-warning. Is there anyway I can make sure that all https://domain.com are redirected to https://www.domain.com before the SSL exchange? Maybe something directly on the Apache server or something in the DNS?

share|improve this question

migrated from stackoverflow.com Nov 9 '12 at 19:51

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

    
DNS is only resolving ip addresses and domains. That won't help you. –  Roger Nov 9 '12 at 14:41
    
I didn't register https://domain.com and I don't have money to do that. - Um, why would that cost you extra? You own domain.com, just make an A record for it and get a certificate that has both names. –  MDMarra Nov 9 '12 at 19:53

2 Answers 2

up vote 5 down vote accepted

Host name verification is a client-side mechanism (as described in the HTTPS specification, RFC 2818, Section 3.1). The client will check that the certificate is valid for the host name it has requested before any HTTP traffic happens (in particular, before any redirection). Apache redirections or DNS changes won't be of any use.

You simply need the web server to present a certificate that is valid for the requested host name.

Some certificates can be valid for multiple host names, by having multiple Subject Alternative Name (SAN) DNS entries, e.g. domain.com and www.domain.com. Some CAs do this by default, some do it for an extra fee.

(Wildcard certificates can also be used to handle multiple host names provided they follow the right pattern such as *.domain.com. Unfortunately, domain.com isn't matched by *.domain.com because the dot is part of the pattern. Some wildcard certs will have both a SAN for domain.com and *.domain.com, in which case it's the SAN mechanism that will be used for domain.com, nothing to do with the wildcard.)

You could also use Server Name Indication (SNI) and have an additional, different certificate on that host for domain.com (next to the one for www.domain.com). Unfortunately, it's not supported by certain clients (possibly old, but they still exist), and it would certainly be pointless, since most CAs issuing a cert for domain.com would certainly include www.domain.com automatically in another SAN anyway.

Either way, if you want to be able to serve https://domain.com at all (even if it's just for a redirection), you'll have to get a new certificate valid for it (at least).

share|improve this answer
    
I'd add that many of the Cert vendors offer one or more Subject Alternative Names for free on their middle tier and higher products. And most allow at least one re-issue where you can add a second name. Check your current cert vendor to see if you can double-up for free. –  Mark Nov 9 '12 at 20:08

The only option to solve your problem without having to buy a second certificate is buying a wild-card certificate for *.domain.com.

But I assume that such certificates are a bit more expensive that a standard certificate and you already have one for your domain therefore I don't see a way to get what you want without spending again money.

BTW: Even buying a second certificate wont' solve all your troubles as I assume you have only one public IP address and therefore you would have to use "Server Name Indication" (SNI) which is not supported in IE on XP.

share|improve this answer
1  
Actually, the *.domain.com wildcard won't help at all for domain.com since the dot isn't part of the pattern matched. What's needed is a cert with multiple SANs: domain.com and www.domain.com. Some CAs do this by default. Wildcards certs tend to work for this because they're often issued with SANs for domain.com and *.domain.com, but it's not the wildcard that's used for this. In addition, there's no need for a second cert and SNI if the new cert is valid for both hosts. –  Bruno Nov 9 '12 at 15:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.