verifying ssl certificates
Christopher N. Deckard
cnd at ecn.purdue.edu
Tue Apr 2 09:40:32 EST 2002
Paul Rubin wrote:
>
> "Christopher N. Deckard" <cnd at ecn.purdue.edu> writes:
> > I was wondering if anyone has some sample code, or could point me at
> > some documentation, to where I can see how to verify SSL
> > certificates after making an SSL connection via sockets. Is it as
> > simple as comparing the response of the server to that of something
> > in a file?
>
> Usually you configure the SSL stack to do this for you. If the
> certificate doesn't verify, the SSL connection won't even open,
> so your application will never get to see an invalid cert.
In other words:
import socket
cert = open('my_cert')
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('host', 'port'))
ss = ssl(s, cert, None)
That last line being the key. Does that do the certificate
validation?
-Chris
More information about the Python-list
mailing list