Getting SSL certificate behind a proxy working with Python requests library from Docker

L. D. Nicolas May
4 min readDec 4, 2020

Context

At work we use a REDCap instance supported by one of our university research institutes. We often write code against the REDCap API to ETL and/or analyze clinical research data for various purposes. For ad hoc jobs, we’re mostly an R shop, and writing R against the API never gives us any trouble.

Problem

As I started building automated pipelines in Python with tools like Apache Airflow, I tried to query the REDCap data with API calls using the Python {requests} library. However, running something like this…

library(requests)r = requests.post(
"https://xxx.yyy.com/api/",
request_dict,
verify=True
)

… resulted in this error:

Traceback (most recent call last):
...
...
...
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='xxx.yyy.com', port=443): Max retries exceeded with url: /api/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)')))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
...

--

--