[issue29334] ssl.SSLObject method getpeercert() is buggy, do_handshake() is strange

Nathaniel Smith report at bugs.python.org
Tue May 23 03:43:31 EDT 2017


Nathaniel Smith added the comment:

Oddly, I expected to run into this with my code using SSLObject in trio [1], but if I connect to python.org:443 and then 'await trio_ssl_stream.do_handshake(); trio_ssl_stream.getpeercert()' it works just fine ... even though when I run the sslbugs.py script I get the same weird results Greg reports. As far as I can tell the logic is identical. So I guess this might potentially be useful to narrow this down :-).

Test code that works:

@trio.run
async def main():
    import trio
    sock = trio.socket.socket()
    addr = await sock.resolve_remote_address(("python.org", 443))
    await sock.connect(addr)
    s = trio.SocketStream(sock)
    client = trio.ssl.SSLStream(
        s, trio.ssl.create_default_context(), server_hostname="python.org")
    await client.do_handshake()
    print(client.getpeercert())

[1] Currently in https://github.com/python-trio/trio/pull/107, eventually will be at https://github.com/python-trio/trio/blob/master/trio/ssl.py

----------
nosy: +njs

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29334>
_______________________________________


More information about the Python-bugs-list mailing list