alekstorm / backports.ssl

UNMAINTAINED - The Python 3.4 standard `ssl` module API implemented on top of pyOpenSSL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python 2.7.11 (Mac) backports.ssl example code does not run

ph-hs opened this issue · comments

commented

This:

import backports.ssl as ssl
import socket

context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_REQUIRED

conn = context.wrap_socket(socket.socket(socket.AF_INET))
conn.connect(('google.com', 443))
print conn.getpeercert()
conn.close()

Results in:

Traceback (most recent call last):
  File "ffo.py", line 4, in <module>
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
AttributeError: 'module' object has no attribute 'SSLContext'