urllib getting SSL certificate info

Ghirai ghirai at ghirai.com
Sat Aug 16 06:51:41 EDT 2008


On Saturday 16 August 2008 12:16:14 Fredrik Lundh wrote:
> Ghirai wrote:
> > Using urllib, is there any way i could access some info about the SSL
> > certificate (when opening a https url)?
> >
> > I'm really interested in the fingerprint.
> >
> > I haven't been able to find anything so far.
>
> you can get some info via (undocumented?) attributes on the file handle:
>  >>> import urllib
>  >>> f = urllib.urlopen("https://mail.google.com/")
>  >>> f.fp
>
> <httplib.SSLFile instance at 0x00CE2508>
> ['issuer', 'read', 'server', 'write']
>
>  >>> f.fp._ssl.issuer()
>
> '/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA'
>
>  >>> f.fp._ssl.server()
>
> '/C=US/ST=California/L=Mountain View/O=Google Inc/CN=mail.google.com'
>
> </F>
>
> --
> http://mail.python.org/mailman/listinfo/python-list


Thanks, that seems to be getting me very close of what i need.

-- 
Regards,
Ghirai.



More information about the Python-list mailing list