Сертификаты являются производственными (не самозаверяющими)
Скрипт прост:
Код: Выделить всё
import requests
print(requests.post('https://my_url.com', cert=('client.pem', 'key.pem'),data='foo', verify='ca.pem'))
Код: Выделить всё
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)
Код: Выделить всё
verify=False
Код: Выделить всё
[ec2-user@ec2-instance ~]$ curl -w "%{http_code}\n" -s -o /dev/null -X POST https://my_url.com --cert client.pem --key key.pem --cacert ca.pem --data-binary "@some_file"
200
Код: Выделить всё
[ec2-user@ec2-instance ~]$ openssl s_client -connect my_url.com:443 -cert client.pem -key key.pem -CAfile ca.pem
CONNECTED(00000003)
depth=2 C = FR, O = ******, CN = ******
verify return:1
depth=1 C = FR, O = ******, OU = ******, organizationIdentifier = ******, CN = ******
verify return:1
depth=0 C = FR, L = ******, O = ******, CN = ******
verify return:1
---
Certificate chain
0 s:C = FR, L = ******, O = ******, CN = ******
i:C = FR, O = ******, OU = ******, organizationIdentifier = ******, CN = ******
a:PKEY: rsaEncryption, 2048 (bit); sigalg: RSA-SHA256
v:NotBefore: Jun 12 22:00:00 2024 GMT; NotAfter: Jun 12 21:59:59 2025 GMT
---
Server certificate
-----BEGIN CERTIFICATE-----
...blah...
-----END CERTIFICATE-----
subject=C = FR, L = ******, O = ******, CN = ******
issuer=C = FR, O = ******, OU = ******, organizationIdentifier = ******, CN = ******
---
Acceptable client certificate CA names
...blah...
---
SSL handshake has read 3450 bytes and written 5346 bytes
Verification: OK
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 2048 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
Подробнее здесь: https://stackoverflow.com/questions/790 ... sl-but-not