I got such certificate :
certificate.base64.cer
JavaScript
x
6
1
-----BEGIN CERTIFICATE-----
2
MIIGGDCCBQCgAwIBAgITcwAHCoPQ7YzgDXiRHQACAAcKgzANBgkqhkiG9w0BAQsF
3
some symbols) (
4
oWt63wOSxGxa3ASu1UFGCd9o+PxnaUA12EGU9A==
5
-----END CERTIFICATE-----
6
And I want to send request using it
api.py
JavaScript
1
8
1
session = requests.Session()
2
session.auth = HTTPBasicAuth('user', 'pass')
3
session.cert = 'path to .cer file'
4
host = 'https://api.com/webservices/MediaPool/?wsdl'
5
session.headers = {'Content-Type': 'application/json'}
6
client = Client(transport=Transport(session=session), wsdl=host)
7
response = client.service.uploadMedia(uploadMediaData={'fileName': image.name, 'fileData': image.read()})
8
but I get
JavaScript
1
2
1
HTTPSConnectionPool(host='some.host', port=443): Max retries exceeded with url: /webservices/MediaPool/?wsdl (Caused by SSLError(SSLError(9, '[SSL] PEM lib (_ssl.c:4050)'))
2
How to fix that? What is wrong?
Advertisement
Answer
Python requests trust certificate in cer-file
session.cert
is used for authentication using client certificates. For specifying the trusted CA session.verify
must be used instead. For more see the documentation.