Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python [SSL] PEM lib (_ssl.c:3309) error when verifying certificate

I am trying to send POST messages to a web server. In order to do that, I am using python requests and trying to pass the requests.post method a certificate as an argument.

It looks something like that:

    if method_type == METHOD_TYPE_GET:
        resp = requests.get(base_url, data=request_data, verify=True, headers=headers, cert=certificate)
    if method_type == METHOD_TYPE_POST:
        resp = requests.post(base_url, data=request_data, verify=True, headers=headers, cert=certificate)
    return resp

When 'certificate' is the path to a pem file, which contains the server's certificate. The file is of format:

-----BEGIN CERTIFICATE-----

-base64data-

-----END CERTIFICATE-----

When I try to execute the post method, I get an Exception of: [SSL] PEM lib (_ssl.c:3309)

Any idea what the problem is?

like image 881
Max Vlaschuk-Gorelik Avatar asked Dec 09 '25 09:12

Max Vlaschuk-Gorelik


1 Answers

please check your openssl - configuration file setting for the following parameter extendedKeyUsage = clientAuth

like image 57
karthik Avatar answered Dec 11 '25 03:12

karthik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!