0
votes

I have an Amazon linux 2 VM and I am making a python requests from this VM. For making the request I am using self signed certificate.

I have appended the self signed certificate file content to the file "/etc/pki/tls/certs/ca-bundle.crt".

The CURL command works fine, however when making requests using python's requests method it throws below error.

ERROR : (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)'))

I tried using "verify" parameter for Python requests method by providing path of both "MyAppcert.crt" as well as "ca_bundle.crt" files, however both approach fails.

import requests
requests.get("https://<my-endpoint>:8888/", verify="/home/ec2-user/ssl_cert/MyAppcert.crt")

This same use case works fine on Windows server.

Any help will be appreciated.

Regards,

Rahul Kumbhar

do you have the certifi module installed? If not: do pip install certifi - Marijn Kneppers
Different TLS stacks have slightly different ways of validating certificates. Make sure that the self-signed certificate has actually basic constraints CA:true enabled (check with openssl x509 -in file.pem -text) - Steffen Ullrich
@MarijnKneppers: certifi does not help with self-signed certificates. It is for certificates issued by public CA only. - Steffen Ullrich