ktls-utils: question about certificate verification
Subsystems (2)
hi Olga,
A few weeks ago you and Chuck were discussing duplication requirements of the hostname in the CN field versus SAN extension in the certificate:
https://lore.kernel.org/linux-nfs/CAN-5tyENK71L1C=6NwdB4mkxxf1qYZ2-4e-p8FQM=SmA3tMT_g@mail.gmail.com/
For what it's worth, my own testing showed that the SAN DNS: element doesn't need to duplicate the CN.
This is especially relevant in the case where the full DNS name is > 64 chars, which is not strictly allowed as a CN (and openssl for example enforces that limit).
In that case, it works to put the short hostname in the CN, and the full DNS name in a SAN DNS: extension. There is no need to duplicate the CN entry in the SAN extension.
I also noted that using a wildcard CN (e.g. "*.acme.com") does not work.
I've yet to test mounting by IP, but will do so soon.
best wishes,
calum.
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
thanks again,
calum.
Quoted 14 lines · Calum Mackay
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Quoted 8 lines
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
I have tried to use a wildcard in the SAN and that didn't work for me. How about you? Specifically, I tried in the SAN "DS:netapp*.linux.fake" and tried to mount netapp119.linux.fake which failed with "certificate owner unexpected" (meaning certificate didnt find anything match to netapp119.linux.fake.
Quoted 3 lines
thanks again,
calum.
Quoted 21 lines · Olga Kornievskaia
Quoted 20 lines · Calum Mackay
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Quoted 8 lines
Quoted 2 lines
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
I have tried to use a wildcard in the SAN and that didn't work for me. How about you? Specifically, I tried in the SAN "DS:netapp*.linux.fake" and tried to mount netapp119.linux.fake which failed with "certificate owner unexpected" (meaning certificate didnt find anything match to netapp119.linux.fake.
hi Olga, yes, exactly the same here. Wildcards don't work for me in either CN or SAN.
What I've been doing in my testing, when the host full DNS name is > 64 chars, is to use the simple hostname as the CN (for ease of identification in e.g. "trust list") and the full DNS name in a SAN DNS: extension, and that is working well.
thanks,
calum.
Quoted 23 lines · Calum Mackay
Quoted 21 lines · Olga Kornievskaia
Quoted 20 lines · Calum Mackay
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
I have tried to use a wildcard in the SAN and that didn't work for me. How about you? Specifically, I tried in the SAN "DS:netapp*.linux.fake" and tried to mount netapp119.linux.fake which failed with "certificate owner unexpected" (meaning certificate didnt find anything match to netapp119.linux.fake.
I don't know if this helps, but at least for the OpenSSL libraries, wildcards can optionally match a component in a DNS name or multiple components. For example:
*.linux.fake could match netapp119.linux.fake, but not netapp119.subnet.linux.fake
OR
*.linux.fake could match both netapp119.linux.fake and netapp119.subnet.linux.fake
OR
*.linux.fake does not match anything.
Which of the above is true depends on whether an argument to X509_check_host() is set to X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS, 0, or X509_CHECK_FLAG_NO_WILDCARDS.
- I made X509_CHECK_FLAG_NO_WILDCARDS the default in FreeBSD, but it can optionally be set to either of the other values.
I don't know if you guys use a similar call? rick
Quoted 13 lines
hi Olga, yes, exactly the same here. Wildcards don't work for me in either CN or SAN.
What I've been doing in my testing, when the host full DNS name is > 64 chars, is to use the simple hostname as the CN (for ease of identification in e.g. "trust list") and the full DNS name in a SAN DNS:
extension, and that is working well.thanks,
calum.
Quoted 43 lines · Rick Macklem
Quoted 23 lines · Calum Mackay
Quoted 21 lines · Olga Kornievskaia
Quoted 20 lines · Calum Mackay
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
I have tried to use a wildcard in the SAN and that didn't work for me. How about you? Specifically, I tried in the SAN "DS:netapp*.linux.fake" and tried to mount netapp119.linux.fake which failed with "certificate owner unexpected" (meaning certificate didnt find anything match to netapp119.linux.fake.
I don't know if this helps, but at least for the OpenSSL libraries, wildcards can optionally match a component in a DNS name or multiple components. For example:
*.linux.fake could match netapp119.linux.fake, but not netapp119.subnet.linux.fake
OR
*.linux.fake could match both netapp119.linux.fake and netapp119.subnet.linux.fake
OR
*.linux.fake does not match anything.
Quoted 7 lines
Which of the above is true depends on whether an argument to
X509_check_host()is set toX509_CHECK_FLAG_MULTI_LABEL_WILDCARDS, 0, orX509_CHECK_FLAG_NO_WILDCARDS.
- I madeX509_CHECK_FLAG_NO_WILDCARDSthe default in FreeBSD, but it can optionally be set to either of the other values.I don't know if you guys use a similar call? rick
Thanks Rick.
The Linux handshake implementation (tlshd, in pkg ktls-utils) uses the gnutls library, rather than openssl. gnutls does consider wildcards when hostname matching by default, and tlshd doesn't disable that.
I've just noticed, in the gnutls docs:
https://gnutls.org/manual/gnutls.html#X509-certificate-API
Quoted 2 lines
gnutls_x509_crt_check_hostname2
… [wildcards] are only considered if the domain name consists of three components or more, and the wildcard starts at the leftmost position
tlshd uses gnutls_certificate_verify_peers3() rather than gnutls_x509_crt_check_hostname2(), and the …peers3() function does check the hostname, so presumably the same restriction applies.
That would suggest that Olga's example ["netapp*.linux.fake"] wouldn't be expected to work, since the wildcard isn't at the leftmost position.
However, my testing was using "*.dept.domain.com", which appears to follow the rule above.
gnutls doesn't seem to have quite the same level of option granularity that you show above for openssl.
I'll test further later today.
cheers,
calum.
Quoted 14 lines
Quoted 14 lines
hi Olga, yes, exactly the same here. Wildcards don't work for me in either CN or SAN.
What I've been doing in my testing, when the host full DNS name is > 64 chars, is to use the simple hostname as the CN (for ease of identification in e.g. "trust list") and the full DNS name in a SAN DNS:
extension, and that is working well.thanks,
calum.
Signature · 3 lines
Calum Mackay Linux Kernel Engineering Oracle Linux and Virtualisation
Quoted 62 lines · Calum Mackay
Quoted 43 lines · Rick Macklem
Quoted 23 lines · Calum Mackay
Quoted 21 lines · Olga Kornievskaia
Quoted 20 lines · Calum Mackay
Quoted 11 lines · Olga Kornievskaia
Hi Calum,
My surprise was to find that having the DNS name in CN was not sufficient when a SAN (with IP) is present. Apparently it's the old way of automatically putting the DNS name in CN and these days it's preferred to have it in the SAN.
If the infrastructure doesn't require pnfs (ie mounting by IP) then it doesn't matter where the DNS name is put in the certificate whether it is in CN or the SAN. However, I found out that for pnfs server like ONTAP, the certificate must contain SAN with ipAddress and dnsName
Noted, thanks very much Olga, that's useful.
Quoted 3 lines
extensions regardless of having DNS in CN. I have not tried doing wildcards (in SAN for the DNS name) but I assumed gnuTLS would accept them. I should try it.
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Wildcard didn't seem to work for me in CN, but I may not have tried it in SAN; I'll do that too.
I have tried to use a wildcard in the SAN and that didn't work for me. How about you? Specifically, I tried in the SAN "DS:netapp*.linux.fake" and tried to mount netapp119.linux.fake which failed with "certificate owner unexpected" (meaning certificate didnt find anything match to netapp119.linux.fake.
I don't know if this helps, but at least for the OpenSSL libraries, wildcards can optionally match a component in a DNS name or multiple components. For example:
*.linux.fake could match netapp119.linux.fake, but not netapp119.subnet.linux.fake
OR
*.linux.fake could match both netapp119.linux.fake and netapp119.subnet.linux.fake
OR
*.linux.fake does not match anything.Quoted 7 lines
Which of the above is true depends on whether an argument to
X509_check_host()is set toX509_CHECK_FLAG_MULTI_LABEL_WILDCARDS, 0, orX509_CHECK_FLAG_NO_WILDCARDS.
- I madeX509_CHECK_FLAG_NO_WILDCARDSthe default in FreeBSD, but it can optionally be set to either of the other values.I don't know if you guys use a similar call? rick
Thanks Rick.
The Linux handshake implementation (tlshd, in pkg ktls-utils) uses the gnutls library, rather than openssl. gnutls does consider wildcards when hostname matching by default, and tlshd doesn't disable that.
I've just noticed, in the gnutls docs:
Quoted 7 lines
https://gnutls.org/manual/gnutls.html#X509-certificate-API
Quoted 2 lines
gnutls_x509_crt_check_hostname2
… [wildcards] are only considered if the domain name consists of three components or more, and the wildcard starts at the leftmost positiontlshd uses
gnutls_certificate_verify_peers3()rather thangnutls_x509_crt_check_hostname2(), and the …peers3() function does check the hostname, so presumably the same restriction applies.
Right. the man page for gnutls_certificate_verify_peers3 does say it follows RFC 6125 for hostname checking.
Quoted 2 lines
That would suggest that Olga's example ["netapp*.linux.fake"] wouldn't be expected to work, since the wildcard isn't at the leftmost position.
Interesting note! Thanks for getting it. I was looking at the rfc 6125 and it has this for the matching rules which to me seemed to mean that my netapp*.linux.fake should have been accepted (but it's a MAY in the RFC so there is that):
The client MAY match a presented identifier in which the wildcard
character is not the only character of the label (e.g., baz*.example.net and *baz.example.net and b*z.example.net would be taken to match baz1.example.net and foobaz.example.net and buzz.example.net, respectively).
Quoted 2 lines
However, my testing was using "*.dept.domain.com", which appears to follow the rule above.
I also tried having a cert with DNS: *.linux.fake and that worked.
Quoted 29 lines
gnutls doesn't seem to have quite the same level of option granularity that you show above for openssl.
I'll test further later today.
cheers,
calum.Quoted 10 lines
Quoted 10 lines
hi Olga, yes, exactly the same here. Wildcards don't work for me in either CN or SAN.
What I've been doing in my testing, when the host full DNS name is > 64 chars, is to use the simple hostname as the CN (for ease of identification in e.g. "trust list") and the full DNS name in a SAN DNS:
extension, and that is working well.Quoted 4 lines
Quoted 4 lines
thanks,
calum.--
Calum Mackay
Linux Kernel Engineering
Oracle Linux and Virtualisation