OpenSSL errors in python requests

... line 496, in _connect_tls_proxy

Your code is trying to use the (new) support for accessing the proxy itself over HTTPS. This is done because you’ve explicitly given that URL as the proxy as https://... and not http://...:

'https' : 'https://proxyip:proxyport'
           ^^^^^^

It is very likely that the proxy itself does not support TLS connections to the proxy. Commonly HTTP proxies have a plain HTTP connections to the proxy only. They still can proxy HTTPS traffic this way, since the client will simply issue a CONNECT request to the proxy to create a tunnel and then use end-to-end TLS between client and server.

Accessing a proxy by HTTPS will add an additional layer of TLS between client and proxy, which is not supported by most proxies. Therefore, you likely need plain HTTP proxy instead:

 'https' : 'http://proxyip:proxyport'
           ^^^^^^

Note that in older versions of the requests library both access with http:// and https:// worked. These older versions had no support for HTTPS to the proxy and simply used plain HTTP even if https:// would be specified.

Leave a Comment