<div dir="ltr"><div><br></div><div>You need to use the ssl option:<br></div><div> </div><div> {customize_hostname_check, </div><div> [{match_fun, public_key:pkix_verify_hostname_match_fun(https)}]}</div><div><br></div><div>to allow wildcard certs!</div><div><br></div><div>Regards Ingela Erlang/OTP team - Ericsson AB<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Den tors 3 okt. 2019 kl 00:22 skrev Dániel Szoboszlay <<a href="mailto:dszoboszlay@gmail.com">dszoboszlay@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I'm trying to connect to the server <a href="http://foobar.example.com" target="_blank">foobar.example.com</a> with ss from an Erlang node. The server presents a wildcard certificate with an <font face="monospace">?'id-ce-subjectAltName'</font> extension that looks like this:</div><div><br></div><div><font face="monospace">{'Extension', {2,5,29,17}, false,<br> [{dNSName, "*.<a href="http://example.com" target="_blank">example.com</a>"},<br> {dNSName, "<a href="http://example.com" target="_blank">example.com</a>"}</font></div><div><font face="monospace"> ]}</font><br></div><div><br></div><div>The peer verification (default one) fails with <font face="monospace">hostname_check_failed</font>. I traced the problem back to <font face="monospace">public_key:verify_hostname_match_default0/2</font> which gets called like this:</div><div><br></div><div><font face="monospace">public_key:verify_hostname_match_default0(</font></div><div><font face="monospace"> {dns_id, "<a href="http://foobar.example.com" target="_blank">foobar.example.com</a>"},<br> {dNSName, "*.<a href="http://example.com" target="_blank">example.com</a>"})<br></font></div><div><br></div><div>This check fails. The function has one clause for matching a <font face="monospace">dns_id</font> against a <font face="monospace">dNSName</font>, and it requires an exact match. It also has a clause that allows wildcards, but that's only for matching a (non-wrapped) fqdn against a <font face="monospace">cn</font> tuple: <a href="https://github.com/erlang/otp/blob/5bf0a8a2a18a8e883792692bdc060e37552b0d08/lib/public_key/src/public_key.erl#L1672-L1675" target="_blank">https://github.com/erlang/otp/blob/5bf0a8a2a18a8e883792692bdc060e37552b0d08/lib/public_key/src/public_key.erl#L1672-L1675</a></div><div><br></div><div>Why isn't the wildcard matching enabled for the <font face="monospace">dns_id</font> against <font face="monospace">dNSName</font> case too? The fqdn against <font face="monospace">cn</font> scenario is only used as a fallback when the certificate doesn't contain an <font face="monospace">?'id-ce-subjectAltName'</font> extension. But as far as I can tell wildcard certificates typically have the extension, instead of (or besides) using a wildcard in the CN (see for example the certificate presented by <a href="https://blog.hu/" target="_blank">https://blog.hu/</a>).</div><div><br></div><div>The <font face="monospace">public_key</font> <a href="http://erlang.org/doc/apps/public_key/using_public_key.html#the-verification-process" target="_blank">User's Guide</a> says: </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(26,26,26);font-family:sans-serif;font-size:16px;background-color:rgb(254,254,254)">In case where the Presented IDs are fetched from the </span><span style="font-family:mono,Courier,monospace;background-color:rgb(243,243,243);color:rgb(26,26,26);font-size:16px">Subject</span><span style="color:rgb(26,26,26);font-family:sans-serif;font-size:16px;background-color:rgb(254,254,254)"> certificate field, the names may contain wildcard characters. The function handles this as defined in </span><span style="font-family:mono,Courier,monospace;font-weight:bold;color:rgb(26,26,26);font-size:16px;background-color:rgb(254,254,254)"><a href="https://tools.ietf.org/html/rfc6125#section-6.4.3" style="color:rgb(27,110,194);text-decoration-line:none" target="_blank">chapter 6.4.3 in RFC 6125</a></span><span style="color:rgb(26,26,26);font-family:sans-serif;font-size:16px;background-color:rgb(254,254,254)">.</span></blockquote><br>But as I understand, chapter 6.4.3 speaks about presented ids <i>in general</i>. Where does this restriction to the subject field come from?<div><br></div><div>Thanks,</div><div>Daniel</div></div>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>