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:
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!
requests can also ignore verifying the SSL certificate if you set verify to False. If you're using a third-party module and want to disable the checks, here's a context manager that monkey patches requests and changes it so that verify=False is the default and suppresses the warning.
SSL certificate_verify_failed errors typically occur as a result of outdated Python default certificates or invalid root certificates. If you're a website owner and you're receiving this error, it could be because you're not using a valid SSL certificate.
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.
This may help as workaround for your issue.
print(requests.get(url, proxies,verify = False))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With