Hm, I wonder if there isn't an even simpler approach that even works with the current asyncio public API. You can pass an already-open socket to create_connection() -- maybe you can use this (also passing ssl=<context>) and it would just work?
On Sat, Apr 5, 2014 at 3:35 PM, Imran Geriskovan <[email protected] > wrote: > On 4/5/14, Guido van Rossum <[email protected]> wrote: > > We would like to support that, but we didn't have the expertise or time > to > > implement it yet. Do you want to help? Can you show a working piece of > code > > that does this with synchnonous sockets? Maybe I could translate that > into > > asyncio code. > > Thank you... > Some straight forward pseudocode is as follows: > > s = create_connection((host, port)) > s = listener.accept()[0] # Or may be accepted from a listener > ... > rd = s.recv(4096) > .... > s.send(wrt) > ... > ctx = create_default_context(Purpose.CLIENT_AUTH) > ctx.load_cert_chain('/dir/some.crt') > s = ctx.wrap_socket(s, server_side = True, do_handshake_on_connect = False) > ... > s.do_handshake() # Optional if you like/need it seperate.. > > > Regards, > Imran > -- --Guido van Rossum (python.org/~guido)
