django-revproxy icon indicating copy to clipboard operation
django-revproxy copied to clipboard

https server not work

Open 77598072 opened this issue 4 years ago • 6 comments

I requested https service, he reported an error.

HTTPSConnectionPool(host='***, port=443): Max retries exceeded with 
url: /** (Caused by SSLError(SSLError("bad handshake:
Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

I read the source code and made the following changes, it work, but I want to know, is there an official way to complete the https request?

class ProxyView(ProxyView):
    upstream = 'https://****/'

    def __init__(self, *args, **kwargs):
        super(ProxyView, self).__init__(*args, **kwargs)
        self.http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where())
  

77598072 avatar Jul 08 '20 02:07 77598072

I have the same issue, is there a way to pass verify=False?

zoobab avatar May 28 '24 11:05 zoobab

Hi @zoobab @77598072!

Thanks for posting the issue. I've set https upstream in several projects without any issue. Are you using same server? If proxy resolves in an internal url you should use http instead of https.

andruten avatar Jun 05 '24 07:06 andruten

I have made the following patch to achieve the same verify=False functionality, but I am sure there is a way to add this feature in a more cleaner way, doing it with sed in a Dockerfile:

# patch for SSL verify false, see https://github.com/jazzband/django-revproxy/issues/116 and https://stackoverflow.com/questions/36600583/python-3-urllib-ignore-ssl-certificate-verification
USER root
RUN sed -i "s/HTTP_POOLS\ =\ urllib3.PoolManager()/HTTP_POOLS\ =\ urllib3.PoolManager(cert_reqs='CERT_NONE')/g" /opt/conda/envs/myproxy/lib/python3.1/site-packages/revproxy/views.py
RUN sed -i "s/import\ urllib3/import\ urllib3\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)/g" /opt/conda/envs/myproxy/lib/python3.1/site-packages/revproxy/views.py

For me it works(tm), but I would welcome an option to ignore SSL verifications, as curl has it with the -k option.

zoobab avatar Jun 05 '24 07:06 zoobab

@zoobab what urllib3 version are you using?

andruten avatar Jun 05 '24 08:06 andruten

@andruten urllib3==2.2.1

zoobab avatar Jun 05 '24 08:06 zoobab

@zoobab Could you try with a 1.26.x version?

andruten avatar Jun 05 '24 09:06 andruten