[New-bugs-announce] [issue45005] Two Layers of SSL/TLS

Mjbmr report at bugs.python.org
Wed Aug 25 15:25:56 EDT 2021


New submission from Mjbmr <mjbmri at gmail.com>:

A simple script, trying connect to second ssl through first sever doesn't work:

import socket, ssl

sock = socket.socket()
sock.connect(('<FIRST_SERVER>', 443))
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
sock = ctx.wrap_socket(sock)
sock.send(b'CONNECT <SECOND_SERVER>:443 HTTP/1.1\r\n\r\n')
print(sock.recv(1024))
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
sock = ctx.wrap_socket(sock)
sock.do_handshake()
sock.send(b'CONNECT ifconf.me:80 HTTP/1.1\r\n\r\n')
print(sock.recv(1024))


b'HTTP/1.1 200 Connection established\r\n\r\n'
Traceback (most recent call last):
  File "C:\Users\Javad\Desktop\4.py", line 15, in <module>
    sock = ctx.wrap_socket(sock)
  File "E:\Categories\Python\Python3.9.6\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "E:\Categories\Python\Python3.9.6\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "E:\Categories\Python\Python3.9.6\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

----------
assignee: christian.heimes
components: SSL
messages: 400291
nosy: christian.heimes, mjbmr
priority: normal
severity: normal
status: open
title: Two Layers of SSL/TLS
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45005>
_______________________________________


More information about the New-bugs-announce mailing list