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 used make-dummmy-cert that comes with apache 2.2 and ssl_mod to make a self-signed certificate. I tried making it for www.example.com, example.com, or *.example.com, but none of them would work for both www.example.com and example.com. The browser would say The certificate is only valid for example.com (or www.example.com or *.example.com respectively)

How do I make a self-signed cert that would work for both cases?

share|improve this question

2 Answers 2

*.example.com won't match example.com because the star only matches subdomains of example.com. *.example.com will however match www.example.com and foo.example.com.

What I think you need to do if you really want to match both is to create a certificate with multiple CNs entries in the SubjectAltName, one for example.com and one for *.example.com (or www.example.com, if you don't need to match any other subdomains). This link might help: http://www.openssl.org/docs/apps/x509v3_config.html#Subject_Alternative_Name_

EDIT:

@Bill Weiss is right, I just checked one of the certs I have from GoDaddy and it has both www.example.com and example.com in the SubjectAltName, and both work in the browser. So it sounds like you can get what you need for cheap.

Good luck,

--jed

share|improve this answer
    
I am going to get a commercial certificate with multiple CNs, any suggestions that are cheap and decent? –  user12145 Apr 14 '10 at 21:06
    
@user12145 Wildcard certificates aren't cheap at all, but the cheapest I've found have been through godaddy.com's certificate service. –  Jed Daniels Apr 14 '10 at 21:09
    
but wildcard certificates won't work for example.com right? I don't need to match subdomains. –  user12145 Apr 14 '10 at 21:13
2  
GoDaddy will throw in a SubjectAltName for example.com. At least, that's been my experience. Talk to your CA about it, they'll help you. –  Bill Weiss Apr 14 '10 at 21:53
3  
Other providers also add a free SubjectAltName: Comodo, DigiCert, and GlobalSign –  Robert Apr 15 '10 at 15:19

Do you have the same content at example.com and www.example.com? As far as I understand this would be a bad idea for SEO and you should redirect one to the other using for instance mod_rewrite.

share|improve this answer
3  
You'd still need SSL for both, or someone visiting the redirect URL via HTTPS will still get the certificate mismatch. –  ceejayoz Jan 30 '13 at 17:35

Your Answer

 
discard

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

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