Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.4.4 (Windows) - backports.ssl example code (modified for Python3) does not run #16

Open
paul-hammant opened this issue Jan 15, 2016 · 0 comments

Comments

@paul-hammant
Copy link

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()) # modified for Python3
conn.close()

Results in:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\backports\ssl\core.py", line 201, in _safe_ssl_call
    return getattr(sock, call)(*args, **kwargs)
  File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1442, in do_handshake
    self._raise_ssl_error(self._ssl, result)    
  File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1187, in _raise_ssl_error
    _raise_current_error()    
  File "C:\Python34\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue
    raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test_outlook_imap.py", line 8, in <module>
    conn.connect(('google.com', 443))
  File "C:\Python34\lib\site-packages\backports\ssl\core.py", line 258, in connect
    self.do_handshake()
  File "C:\Python34\lib\site-packages\backports\ssl\core.py", li�ne 261, in do_handshake
    _safe_ssl_call(False, self._conn, 'do_handshake')
  File "C:\Python34\lib\site-packages\backports\ssl\core.py", line 222, in _safe_ssl_call
    raise SSLError(*e.args)
backports.ssl.core.SSLError: [('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant