Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

358
Views
SSL error with Python requests despite up-to-date dependencies

I am getting an SSL "bad handshake" error. Most similar responses to this problem seem to stem from old libraries, 1024bit cert. incompatibility, etc... I think i'm up to date, and can't figure out why i'm getting this error.

SETUP:

  • requests 2.13.0
  • certifi 2017.01.23
  • 'OpenSSL 1.0.2g 1 Mar 2016'

I'm hitting this API (2048bit certificate key): https://api.sidecar.io/rest/v1/provision/application/device/count/

And getting this error: requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",)

See l.44 of https://github.com/sidecar-io/sidecar-python-sdk/blob/master/sidecar.py

If I turn verify=False in requests, I can bypass, but i'd rather figure out why the certification is failing.

Any help is greatly appreciated; thanks!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The validation fails because the server you access is setup improperly, i.e. it is not a fault of your setup or code. Looking at the report from SSLLabs you see

This server's certificate chain is incomplete. Grade capped to B.

This means that the server sends a certificate chain which is missing an intermediate certificate to the trusted root and thus your client can not build the trust chain. Most desktop browsers work around this problem by trying to get the missing certificate from somewhere else but normal TLS libraries will fail in this case. You would need to explicitly add the missing chain certificate as trusted to work around this problem:

import requests
requests.get('https://api.sidecar.io', verify = 'mycerts.pem')

mycerts.pem should contain the missing intermediate certificate and the trusted root certificate. A tested version for mycerts.pem can be found in http://pastebin.com/aZSKfyb7.

over 4 years ago · Santiago Trujillo Report

0

This may help as workaround for your issue.

print(requests.get(url, proxies,verify = False))
over 4 years ago · Santiago Trujillo Report

0

I fixed it using the python-certifi-win32 package:

pip install python-certifi-win32

or with anaconda

conda install -c conda-forge python-certifi-win32

then you can use:

requests.get(url)
#or
requests.get(url, verify=True)

and the certificate is checked using the Windows Certificate Store.

This only works if the certificate is installed in the Windows Certificate Store.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!