I am trying to use SocksIPy with the ssl module (from stdlib) to grab the remote site certificate, but SocksIPy will not play with ssl.
The code below will connect to check.torproject.org and tell you that we are not using Tor (which means that SocksIPy is not working) (bad).
Not sure if SocksIPy is the best solution for this, but I couldn't find another way to proxy a raw socket (or get pycurl / urllib2 to use SOCKS proxies and provide SSL certificates!).
To clarify, my problem is that the socket is not proxied. I would like to get an ssl certificate with a proxy of my choice, which is not happening.
It seems that I can either have a proxy or SSL, but not both. Help!
import socks import ssl s = socks.socksocket() s.setproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050) ss = ssl.wrap_socket(s) ss.connect(('check.torproject.org', 443)) ss.write("""GET / HTTP/1.0\r Host: check.torproject.org\r\n\r\n""")
python ssl
user1599231 Apr 21 '13 at 22:32 2013-04-21 22:32
source share