<div dir="ltr">> I am writing a SSL/TLS client (using Boost.Beast but underlying it's using<br>> OpenSSL) and although I have set on the SSL context the 'verify_peer' flag,<br>> there is no verification to prove the server presents an X509 which<br>> contains in the Subject Alternative Names the hostname of that server.<br>><br>> As this is probably the dumbest type of attack someone could do (using a<br>> valid certificate with another domain name), I am thinking I'm doing<br>> something wrong. But from the documentation, I saw that using "verify_peer"<br>> should perform all the verifications...<br><br>It verifies the trust chain.  To also verify the peer name, you need to<br>specify the peer name via:<br><br>    SSL_set1_host()<br><br>> Now if not even this simple check is being done, how about expiration of<br>> the certificate, revocation status and other checks? Should they be<br>> performed manually as well?<br><br>No, that's what VERIFY_PEER is for.<br><br>> For now I am using X509_VERIFY_PARAM_set1_host with SSL_CTX_set1_param to<br>> do this specific check.<br><br>That's the slightly less convenient legacy API from OpenSSL 1.0.2.<br>In 1.1.0 and later, you can use SSL_set1_host() (and in some<br>cases also SSL_add1_host()).<br><br>See the SSL_set1_host(3) manpage for details.<div><br></div><div>---------------------------</div><div><br></div><div><br></div><div>Indeed I re-read the docs and it says that users should not assume that hostnames are validated by default without explicitly calling the API, I must've missed that bit and thank you for letting me know. I will shift towards using the newer SSL_set1_host together with some flags (I don't want any wildcards).</div><div><br></div><div>Now just to be extra safe I'm still asking: will the VERIFY_PEER option together with SSL_set1_host instruct OpenSSL to perform all possible checks on the certificate presented by the server such that no security breach remains at this level? Is there anything else that I should call or perform manually?</div><div><br></div><div>-- Theodor</div><div><br></div><div><br></div><div><br></div></div>