Hacker News new | ask | show | jobs
by detaro 3102 days ago
What spec?

RFC6066 (https://tools.ietf.org/html/rfc6066#section-3) says "Currently, the only server names supported are DNS hostnames; however, this does not imply any dependency of TLS on DNS, and other name types may be added in the future (by an RFC that updates this document)." [snip] ""HostName" contains the fully qualified DNS hostname of the server, as understood by the client." [snip] "Literal IPv4 and IPv6 addresses are not permitted in "HostName"."

1 comments

RFC6066, correct.

The "as understood by the client" is very important, apparently.

Furthermore, the name does not need to be in DNS. There is no single source of true DNS anyway (though of course the ~whole world uses the same root servers).

Try it. I just set up a remote server for "snitest", added the IP address to /etc/hosts only, generated a cert for that name only, and got the correct cert via SNI in a local browser.

The same process (minus /etc/hosts modification) also worked for a bare (textual representation of an) IP address.

> Furthermore, the name does not need to be in DNS. There is no single source of true DNS anyway (though of course the ~whole world uses the same root servers).

That is not "furthermore", that is what "as understood by the client" means.

> Try it. I just set up a remote server for "snitest", added the IP address to /etc/hosts only, generated a cert for that name only, and got the correct cert via SNI in a local browser.

That is a fully qualified DNS hostname, by definition. You told both your server that it was a DNS FQDN it should serve and your client that it was a DNS FQDN that it should request, and so they obviously were matched exactly as required by the standard. Whether DNS is involved in the resolution process is irrelevant, especially so given that the standard nowhere specifies the DNS root to use.

> The same process (minus /etc/hosts modification) also worked for a bare (textual representation of an) IP address.

What was the name type in the certificate? That sounds like a bug in the client, and possibly in the server as well.

Is your argument that a name can be a DNS FQDN even if it is not in DNS?

A non-DNS hostname can be treated as fully-qualified since there's no organizational structure to qualify it in.

> What was the name type in the certificate?

The CN? Is the IP address, as specified at cert generation.

> That sounds like a bug in the client, and possibly in the server as well.

Perhaps. I'm not a standards adjudicator.

Nevertheless, it works in the web we have. Tested in nginx, OpenSSL, curl, Firefox.

> Is your argument that a name can be a DNS FQDN even if it is not in DNS?

In the sense of the SNI spec, yes. It would be pointless to require the name to be "in DNS", for the simple reason that there is a potentially infinite number of DNS roots, and protocol standards naturally don't specify instances, only mechanism, so any TLS client could just implement a DNS server that uses the hosts file as its data source for a private DNS root and uses that for resolution, which would be indistinguishable from an implementation that simply skips the pointless encoding and decoding of DNS messages.

The point is to (a) distinguish host names from IP addresses, (b) require fully qualified names, (c) specify the syntax of the host names. Whether the names are actually in any DNS is irrelevant.

> A non-DNS hostname can be treated as fully-qualified since there's no organizational structure to qualify it in.

Sure, and that is fine. The point of the FQDN requirement is that if you send "foobar" as the SNI hostname, you cannot expect the server to match it to a certificate for "foobar.example.com". If both server and client agree on a namespace(/DNS root) where "foobar" is a fully qualified name, then you can expect everything to work just fine. It's not a requirement on how the name is to be verified, only a guarantee on how it may be transformed by protocol participants.

> The CN? Is the IP address, as specified at cert generation.

The CN is essentially deprecated, but matching an IP address in SNI against the CN should be fine. I am just not aware of any way to encode an IP address in SNI. If you had an alternate name IP address in the cert, matching an SNI host name against that would be a bug. If the browser actually accepted a certificate for an IP address when matching against a hostname, that would be a vulnerability.

> Nevertheless, it works in the web we have. Tested in nginx, OpenSSL, curl, Firefox.

Nah, if stuff that contradicts the standard happens, that means that there are things that the standard guarantees to work, but that are broken with the non-compliant implementation. Whether that buggy behaviour is useful to you in some way doesn't change that it's not "working" in any meaningful sense.

Oh, and if by OpenSSL you mean the command line tools: Yes, with those it does work correctly. If you specify the SNI name 1.2.3.4, that is the DNS hostname 1.2.3.4, which should indeed be correctly matched by the server against any certs for alternate DNS name 1.2.3.4, or possibly against certs for CN 1.2.3.4, but not certs for alternate name IP address 1.2.3.4.

> Whether that buggy behaviour is useful to you in some way doesn't change that it's not "working" in any meaningful sense.

I sense that you mean "working" as according to spec. I mean "working" as in practice. In my line of work, the latter is the only meaningful sense.

FWIW, this is not new behaviour, it has worked for at least a decade in various applications.

And yes, OpenSSL the command line tools. I'm not sure what you're talking about though, I've never seen a cert tied to an IP address. What representation would be encoded? My original assertion does not require any such thing.

I'm really not sure what we are disagreeing about any more. If you go back to my original comment, I don't think you'll find it controversial.

> I sense that you mean "working" as according to spec. I mean "working" as in practice. In my line of work, the latter is the only meaningful sense.

The idea that something that isn't working according to spec is supposedly working in practice is almost always an illusion.

> FWIW, this is not new behaviour, it has worked for at least a decade in various applications.

Well, yeah, buggy software is nothing new, that's true.

> And yes, OpenSSL the command line tools. I'm not sure what you're talking about though, I've never seen a cert tied to an IP address. What representation would be encoded?

You could put it in dotted-quad syntax into the CN field of the DN of the certificate's subject (I'm not sure that was ever explicitly allowed, but that was commonly implemented and that stuff is a mess anyhow, which is part of why alternative names were invented--and, as I mentioned, the CN is deprecated and at least Chrome nowadays ignores it unconditionally). The modern, correct way to encode an IP address as the subject of an X.509 certificate is in a subject alternative name field of type iPAddress, as specified here, 5th paragraph:

https://tools.ietf.org/html/rfc5280#page-36

Really, it's probably a stupid idea to have certificates for IP addresses, which is probably the reason why SNI does not support IP addresses ... but PKIX does nevertheless specify certificates for IP addresses.

> I'm really not sure what we are disagreeing about any more. If you go back to my original comment, I don't think you'll find it controversial.

Your claim that you could specify an IP address in SNI is still wrong. As for the other options, it depends on the exact definitions of those terms, they are probably partially wrong. You can not have anything but a fully qualified DNS hostname in SNI, by definition. Whatever you put into that field is by spec to be interpreted by the server as a DNS FQDN, as is the matching SAN field in candidate certificates, and the client must not cast an IP address specified by the user to be reinterpreted as a host name (or else, the server might respond with the certificate for DNS:*.4 when the user has requested https://1.2.3.4/, instead of the default certificate for IP:1.2.3.4 that would be returned when no SNI is present, thus leading to a connection failure even though the spec guarantees that the connection will work).