Python response.post to Posit Connect skips SSL verification

Hi,

I currently skip SSL certification when I read a pin (a ZIP flie) via WorkBench with the following line:
httr::set_config(config(ssl_verifypeer = FALSE, ssl_verifyhost = FALSE))

May I know how to disable the SSL verification in Python? I tried board.pin_upload, but it asked for SSL certification. So, I tried requests package with the following Python codes:

session = requests.Session()
session.verify = False

with open('FILE', 'rb') as f:
response = requests.post('URL:3939', files={'file': f},
headers= {'Authorization': 'Key API_KEY'},
params={'api_key': 'API_KEY'}, verify=False)

The error message is:
requests.exceptions.SSLError: HTTPSConnectionPool(host='URL', port=3939): Max retries exceeded with url: /?api_key=API_KEY (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2406)')))

The url: https://URL:3939/?api_key=API_KEY works. It can open the "Content" page on a web browser.

Best,
Jeanne

You should be able to pass verify=False to requests.post() as described in the requests documentation, but you may also want to consider asking your administrator to fix your certificate situation.

1 Like