HTTPS proxy server python
Question: I have a problem with my ssl server (in Python). I set the SSL proxy
connection in my browser, and try to connect to my ssl server.

This is the server:

    
    
    import BaseHTTPServer, SimpleHTTPServer
    import ssl
    
    httpd = BaseHTTPServer.HTTPServer(('0.0.0.0', 443), SimpleHTTPServer.SimpleHTTPRequestHandler)
    httpd.socket = ssl.wrap_socket (httpd.socket, server_side=True, certfile='server.crt', keyfile='server.key', do_handshake_on_connect=False)
    httpd.serve_forever()
    

This is the error:

    
    
    SSLError: [SSL: HTTPS_PROXY_REQUEST] https proxy request (_ssl.c:1750)
    

I try to connect to the server in the browser. its work if I went to address
"<https://127.0.0.1:443>". But, if I use in the server to proxy, I get the
error...

How can I fix this?


Answer: I don't think you understand how a proxy server for HTTPS works.

What you are doing is to create a plain HTTPS server. What you should do is to
create a HTTP server which handles the CONNECT request and creates a tunnel to
the requested target. See
<http://en.wikipedia.org/wiki/HTTP_tunnel#HTTP_CONNECT_tunneling>

