PyOpenSSL: Force SSL negotiations without sending/receiving?
Is it possible to force PyOpenSSL into performing the SSL negotiation (and, specifically, retrieving the peer's certificate) w开发者_开发问答ithout trying to send/receive data?
Currently, with this code:
ssl_soc = SSL.Connection(self._mk_ctx(), plain_soc)
ssl_soc.set_connect_state()
cert = ssl_soc.get_peer_certificate()
The call to get_peer_certificate
returns None
, but once I've called, eg, ssl_soc.write("hello")
, get_peer_certificate
starts returning the certificate like I'd expect.
Err, clearly I need to RTFM a little harder. I was looking for the do_handshake
method: http://packages.python.org/pyOpenSSL/openssl-connection.html
精彩评论