I’m trying to set up a connection using ssl between a client and a server that I develop.
Base on this : http://bobthegnome.blogspot.fr/2007/08/making-ssl-connection-in-python.html
I created a simple connection and it work. But I want to improve it by adding a client authentication. So I found that some people use socket.warp_socket .
Here is an example :
bindsocket = socket.socket()
bindsocket.bind(('127.0.0.1', 9998))
bindsocket.listen(5)
while True:
newsocket, fromaddr = bindsocket.accept()
connstream = ssl.wrap_socket(newsocket,
server_side=True,
certfile="srv.crt",
keyfile="srv.key",
ssl_version=ssl.PROTOCOL_TLSv1)
deal_with_client(connstream)
What is the difference between these two? Witch one is the best (in my case)?
thanks
There is no difference.
socket.ssl()is a deprecated method that callssocket.wrap_socket()underneath, just does some checking whether python has been compiled with SSL support (whichimport sslwill do for you in any case).