I want to create a socket, then wrap it into ssl.create_default_context, and then send the message via the Tor Network. Using the wrapper works fine, but sending it by proxy does not. I am not trying to hit a .onion site.

I am using socks for this, and the code is:

socks.set_default_proxy(socks.PROXY_TYPE_SOCKS5, "", 9050, True)
socket.socket = socks.socksocket

sock = socket.socket(socket.AF_INET)
sslContext = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile='..')
sslContext.load_cert_chain(certfile="...", keyfile="...")
conn = sslContext.wrap_socket(sock, server_hostname="example.com")

conn.connect((BHost, int(BPort)))

No error messages is generated, the message reaches the destination, but it is not routed via Tor. Tor is running on port 9050 and torify is working.

What am I doing wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.