<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi,<div>I'm experiencing some unexpected (in my opinion - and I might be in the wrong here) behavior in hostname checking the OpenSSL CLI utils.</div><div>I'm trying to verify the hostname of a certificate which has CN=<a href="http://mysite.com">mysite.com</a> and altSubj=localhost (was generated by pyca/cryptography example - <a href="https://cryptography.io/en/latest/x509/tutorial/#creating-a-self-signed-certificate">https://cryptography.io/en/latest/x509/tutorial/#creating-a-self-signed-certificate</a>) and the check always fails on hostname mismatch.</div><div>I tried the following:</div><div>1. openssl x509 -in certificate.pem -checkhost <a href="http://mysite.com">mysite.com</a></div><div>2. openssl verify -verify_hostname <a href="http://mysite.com">mysite.com</a> <span class="gmail-gr_ gmail-gr_359 gmail-gr-alert gmail-gr_gramm gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-Grammar gmail-only-ins gmail-doubleReplace gmail-replaceWithoutSep" id="gmail-359" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat"><span class="gmail-gr_ gmail-gr_396 gmail-gr-alert gmail-gr_gramm gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-Grammar gmail-only-ins gmail-doubleReplace gmail-replaceWithoutSep" id="gmail-396" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">certificate</span></span>.<span class="gmail-gr_ gmail-gr_357 gmail-gr-alert gmail-gr_spell gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-ContextualSpelling gmail-ins-del gmail-multiReplace" id="gmail-357" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat">pem</span></div><div><span class="gmail-gr_ gmail-gr_357 gmail-gr-alert gmail-gr_spell gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-ContextualSpelling gmail-ins-del gmail-multiReplace" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat"><br></span></div><div>I could see in the code that they both use X509_check_host and they both call it with flags=0.</div><div>The thing is, that when the flags=0, X509_check_host will call do_X509_check that will verify only the altSubjNames and not the CN in the Subj.</div><div>I tried to find a way to set the flags to X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT using a CLI flag or config but there is no such option.</div><div><br></div><div>Was it meant to work like this? am I missing something?</div><div><br></div><div>Thanks!</div></div></div></div></div></div></div>