HTTPS proxy server python

2024/10/12 4:26:06

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 sslhttpd = 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

https://en.xdnf.cn/q/118237.html

Related Q&A

Python 2.7.6 + unicode_literals - UnicodeDecodeError: ascii codec cant decode byte

Im trying to print the following unicode string but Im receiving a UnicodeDecodeError: ascii codec cant decode byte error. Can you please help form this query so it can print the unicode string properl…

Retrieving data from Quandl with Python

How can I get the latest prices from a Quandl dataset with the Python API (https://www.quandl.com/help/python)? On https://www.quandl.com/help/api, it says "You can use rows=n to get only the fir…

Django: Using same object how to show 2 different results in django template?

Using the same object how to SHOW 2 different results using django template ?In one page there are two divs, it should show different information using the same object.INPUTobject data has follows[{&q…

Override attribute access precedence having a data descriptor

I have a bunch of instances of a MongoEngine model. And the profiler shows that a lot of time is spent in __get__ method of MongoEngine model fields:ncalls tottime percall cumtime percall filename:…

Understanding pythons reverse slice ( [::-1] )

I always thought that omitting arguments in the python slice operation would result into:start = 0 end = len(lst) step = 1That holds true if the step is positive, but as soon as the step is negative, l…

How to print list elements (which are also lists) in separated lines in Python

Ive checked the post and answers on the SO post Printing list elements on separated lines in Python, while I think my problem is a different one.What I want is to transform:lsts = [[1], [1, 1], [1, 2, …

Python3 threading, trying to ping multiple IPs/test port simultaineously

Full (non-working) code belowFull (working, w/o threading) code here: http://pastebin.com/KUYzNtT2Ive written a small script that does the following:Pull network information from a database Ping each I…

How to print a list of numbers without square brackets?

Im generating a list of random digits, but Im struggling to figure out how to output the digits in a single row without the square brackets?import random def generateAnswer(answerList):listofDigits =…

How to save plotly offline by running my script

I am using below code in my jupyter notebook.import pandas as pd import numpy as np %matplotlib inlinefrom plotly import __version__ from plotly.offline import download_plotlyjs, init_notebook_mode, pl…

Same output of the Keras model

I have a Keras model for predicting moves in the game. I have an input shape of (160,120 ,1). I have the following model with an output of 9 nodes:from keras.models import Sequential from keras.layers.…