问题原文
原帖链接 · Joshua Schroijen · CC BY-SA 4.0
I have a pretty simple question. Suppose I have a domain a.example and I add a CNAME record for the apex/root of that domain pointing to another domain I own: b.example. Suppose now that I want to support HTTPS: if you go to https://a.example you end up at https://b.example and have a HTTPS connection with b.example and had one with a.cexampleom.
In this case, do I need separate SSL certificates for both a.example and b.example? Or can I use the same one for both given that a.example and b.example are both in the SAN (Subject Alternate Name) list of the certificate? In fact, given that I end up at b.example, do I even need a certificate for a.example or have it in a SAN list, given that I'm never actually connecting to a server hosting a.example, just getting redirected at the DNS level?
已采纳解答
原帖链接 · Patrick Mevzek · CC BY-SA 4.0
Lots of things to unpack:
you are not redirected at the DNS level since "redirection" is an HTTP feature, and does not exist in the DNS. For your needs, DNS maps names to IP addresses of servers, either directly (
AandAAAArecords) or indirectly (through one or moreCNAMErecords). The end results is the same: a given name maps to one or more IP addresses (or an error), and this is far before any HTTP stuff happenedfor any given set of names, and websites using them, you are free to use as many certificates as you want "mixing" names together in the SAN extension; there are practical limits, often around 100 names, enforced by CA; there are also operational consequences: 1) you need to validate all names at certificate issuance, 2) they share fate: if certificate is revoked because of one of the name, all others are without certificate anymore also (until a new certificate is generated for those names or a subset); in theory - but I pretty much believe no CA does it even if it is written clearly in CABForum guidelines: if any of the domain name is not renewed and hence gets deleted, or if any of their registrant changes, the certificate should be revoked too; which is why in general, besides the case of
example.com+www.example.com(2 separate names for the computer, but often the exact same content), it is best to avoid certificates mixing names"if you go to https://a.example you end up at https://b.example", sure but the steps are as follows:
a.examplename is resolved through the DNS to some IP addresses- the browser connects to that, at the IP level, then TCP, then TLS
- for the TLS handshake to fully complete here and go to next step, the server HAS TO provide a certificate that covers for the name
a.exampleas this is where it connects (the certificate can list other names as well or not, this is irrelevant here); if this certificate is not handed, the TLS handshake fails and everything stops here. You never reachb.example - If TLS handshake finished properly, the browser can finally start his HTTP messages, so he will ask server "please give me content for
a.example." and server will reply: nope, please follow this redirection tohttps://b.example - Now browser starts everything again from the first point in this list, exactly the same, but now with name
b.example. It does not matter howa.exampleandb.exampleresolve at the DNS level (sane IP or not).
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
