On Wednesday 20 August 2008 00:05:47 Jean-Paul Calderone wrote:
Thanks, i'll go with PyOpenSSL, it seems easier, and has decent docs :)
--
Regards,
Ghirai.
I don't know about M2Crypto. Here's some sample code for PyOpenSSL:
>
from socket import socket
from OpenSSL.SSL import Connection, Context, SSLv3_METHOD
s = socket()
s.connect(('goo gle.com', 443))
c = Connection(Cont ext(SSLv3_METHO D), s)
c.set_connect_s tate()
c.send('GET / HTTP/1.1\r\n\r\n')
cert = c.get_peer_cert ificate()
print cert.get_issuer ().get_componen ts()
print cert.get_subjec t().get_compone nts()
>
When I run this, I get:
>
[('C', 'ZA'), ('O', 'Thawte Consulting (Pty) Ltd.'), ('CN', 'Thawte SGC
CA')] [('C', 'US'), ('ST', 'California'), ('L', 'Mountain View'), ('O',
'Google Inc'), ('CN', 'www.google.com ')]
>
>
>
from socket import socket
from OpenSSL.SSL import Connection, Context, SSLv3_METHOD
s = socket()
s.connect(('goo gle.com', 443))
c = Connection(Cont ext(SSLv3_METHO D), s)
c.set_connect_s tate()
c.send('GET / HTTP/1.1\r\n\r\n')
cert = c.get_peer_cert ificate()
print cert.get_issuer ().get_componen ts()
print cert.get_subjec t().get_compone nts()
>
When I run this, I get:
>
[('C', 'ZA'), ('O', 'Thawte Consulting (Pty) Ltd.'), ('CN', 'Thawte SGC
CA')] [('C', 'US'), ('ST', 'California'), ('L', 'Mountain View'), ('O',
'Google Inc'), ('CN', 'www.google.com ')]
>
>
--
Regards,
Ghirai.