Title: misleading error message from ssl.get_server_certificate() when bad port
Type: behavior Stage:
Components: SSL Versions: Python 3.6
Status: open Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: benjamin.peterson, cedricvanrompay, christian.heimes
Priority: normal Keywords:

Created on 2018-12-05 21:24 by cedricvanrompay, last changed 2018-12-06 05:42 by benjamin.peterson.

Messages (2)
msg331171 - (view) Author: Cédric Van Rompay (cedricvanrompay) Date: 2018-12-05 21:24
When calling ssl.get_server_certificate() with a bad port number (I used 80 when I should have been using 443), the error raised is a bit misleading:

    >>> import ssl
    >>> ssl.get_server_certificate(('',80))
    SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:847)

"SSL: wrong version number" seems to indicate that there is a mismatch between SSL versions supported by the client and the ones supported by the server. When here I guess the problem would better be described as "there is no SSL available at this address+port".
msg331205 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2018-12-06 05:42
Note this is just the error that OpenSSL produces. There isn't a whole Python can do to change it.
Date User Action Args
2018-12-06 05:42:59benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg331205
2018-12-05 21:24:32cedricvanrompaycreate