Python 在 cer 文件中请求信任证书
Python requests trust certificate in cer-file
我得到了这样的证书:
证书。base64.cer
-----BEGIN CERTIFICATE-----
MIIGGDCCBQCgAwIBAgITcwAHCoPQ7YzgDXiRHQACAAcKgzANBgkqhkiG9w0BAQsF
...(some symbols)
oWt63wOSxGxa3ASu1UFGCd9o+PxnaUA12EGU9A==
-----END CERTIFICATE-----
我想用它发送请求
api.py
session = requests.Session()
session.auth = HTTPBasicAuth('user', 'pass')
session.cert = 'path to .cer file'
host = 'https://api.com/webservices/MediaPool/?wsdl'
session.headers = {'Content-Type': 'application/json'}
client = Client(transport=Transport(session=session), wsdl=host)
response = client.service.uploadMedia(uploadMediaData={'fileName': image.name, 'fileData': image.read()})
但我明白了
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)'))
如何解决?怎么了?
Python requests trust certificate in cer-file
session.cert
用于使用客户端证书进行身份验证。必须使用 session.verify
来指定受信任的 CA。有关详细信息,请参阅 the documentation。
我得到了这样的证书:
证书。base64.cer
-----BEGIN CERTIFICATE-----
MIIGGDCCBQCgAwIBAgITcwAHCoPQ7YzgDXiRHQACAAcKgzANBgkqhkiG9w0BAQsF
...(some symbols)
oWt63wOSxGxa3ASu1UFGCd9o+PxnaUA12EGU9A==
-----END CERTIFICATE-----
我想用它发送请求
api.py
session = requests.Session()
session.auth = HTTPBasicAuth('user', 'pass')
session.cert = 'path to .cer file'
host = 'https://api.com/webservices/MediaPool/?wsdl'
session.headers = {'Content-Type': 'application/json'}
client = Client(transport=Transport(session=session), wsdl=host)
response = client.service.uploadMedia(uploadMediaData={'fileName': image.name, 'fileData': image.read()})
但我明白了
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)'))
如何解决?怎么了?
Python requests trust certificate in cer-file
session.cert
用于使用客户端证书进行身份验证。必须使用 session.verify
来指定受信任的 CA。有关详细信息,请参阅 the documentation。