You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using pyopenssl to connect to a server, the pyopenssl client side code doesn't verify that the server's certificate is valid for the target hostname.
Usually, the application code requests which hostname the server certificate should match.
This can be done with openssl as explained on https://wiki.openssl.org/index.php/Hostname_validation
I couldn't find support in pyopenssl for requesting this check.
I'll suggest patches to add this functionality.
The above is example code, based on the pyopenssl client.py example code, which performs a connection to server https://mismatch.kuix.de
The certificate used by that server isn't valid for that hostname, and should get rejected.
However, the above example code connects to the host without reporting a failure.
Note the commented out line "client_ssl.set_verify_host(hostname)". I'll supply patches to add this new API. With the patches and that line enabled, pyopenssl will correctly report a failure.
Activity
kaie commentedon Oct 9, 2018
kaie commentedon Oct 9, 2018
The above is example code, based on the pyopenssl client.py example code, which performs a connection to server https://mismatch.kuix.de
The certificate used by that server isn't valid for that hostname, and should get rejected.
However, the above example code connects to the host without reporting a failure.
Note the commented out line "client_ssl.set_verify_host(hostname)". I'll supply patches to add this new API. With the patches and that line enabled, pyopenssl will correctly report a failure.
bortzmeyer commentedon Dec 14, 2019
OpenSSL, since 1.1.0, has a
X509_check_host. It could be sufficient to just export it and then rely on it.tiran commentedon Dec 14, 2019
Even better, the feature is already available since OpenSSL 1.0.2.
reaperhulk commentedon Aug 14, 2020
We expose the ability to do this properly in pyopenssl now.