sockets - Python 3.4 - Connect to imap server using only TLSv1 -


i'm trying connect imap mail server using tlsv1 in python 3.4.

after troubleshooting (most of determined mail server supports tlsv1), i've found can connect server using openssl:

openssl s_client -connect mail.calpoly.edu:993 -tls1 

as sockets package in python 2.7:

python 2.7.6 (default, mar 22 2014, 22:59:56) [gcc 4.8.2] on linux2 type "help", "copyright", "credits" or "license" more information. >>> import ssl >>> import socket >>> >>> sock = socket.socket(socket.af_inet, socket.sock_stream) >>> ssl_sock = ssl.wrap_socket(sock=sock, ssl_version=ssl.protocol_tlsv1) >>> ssl_sock.connect(('mail.calpoly.edu', 993)) >>> ssl_sock <ssl.sslsocket object @ 0x7fbab6e7aed8> 

when try connect in python 3.4, however, handshake error:

python 3.4.0 (default, apr 11 2014, 13:05:11)  [gcc 4.8.2] on linux type "help", "copyright", "credits" or "license" more information. >>> import ssl >>> import socket >>>  >>> sock = socket.socket(socket.af_inet, socket.sock_stream) >>> ssl_sock = ssl.wrap_socket(sock=sock, ssl_version=ssl.protocol_tlsv1) >>> ssl_sock.connect(('mail.calpoly.edu', 993)) traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/usr/lib/python3.4/ssl.py", line 841, in connect     self._real_connect(addr, false)   file "/usr/lib/python3.4/ssl.py", line 832, in _real_connect     self.do_handshake()   file "/usr/lib/python3.4/ssl.py", line 805, in do_handshake     self._sslobj.do_handshake() ssl.sslerror: [ssl: sslv3_alert_handshake_failure] sslv3 alert handshake failure (_ssl.c:598) 

it seems python 3.4 tries use sslv3 though tell not to.

does know why happening , how can work around it?

p.s. - i'll using imaplib in code interface server. used sockets in example highlight doesn't seem issue imaplib package.

...most of determined mail server supports tlsv1

does mean server croak on other handshake? typically client start best protocol can (like tlsv12) , if server not support it, reply lower protocol (like tlsv1 in case). but, servers broken or there broken middlebox in between.

[ssl: sslv3_alert_handshake_failure] sslv3 alert handshake failure .... seems python 3.4 tries use sslv3 though tell not to. 

not necessarily. tls1.0 ssl3.1 , lots of tls handling done sslv3 functions. error message might confusing.

when checking server out some tool looks like, it

  • will return "unsupported protocol" ssl3.0, fine.
  • will croak with tls1.1 instead of returning tls1.0. means server or middlebox in between broken.
  • will accept rc4-md5 cipher , croak on other ciphers. makes broken because should return "no shared ciphers" on unsupported ciphers instead.

rc4-md5 reason not working python 3.4. contrary python 2.7 there more secure default cipher set in python 3.4 includes "..:!md5". means python 3.4 client not offer rc4-md5 cipher , handshake fail because of no shared ciphers.

fix fix broken server. workaround might explicitly set cipher connecion, i.e. wrap_socket( ... , ciphers="rc4-md5") or similar


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -