Python – how to use CRT and key file in requests

  Kiến thức lập trình

I am using the requests library in Python. The API request works fine in Postman after adding the certificate and key.

Here is my code:

import requests
import json

url= ""

cert_path = ""
key_path = ""

try:
    payload = {"key": "val"}
    headers = {'content-type': 'application/json'}

    response = requests.request('POST',url, data=json.dumps(payload),headers=headers, cert=(cert_path,key_path))

    print("Response status code:", response.status_code)
    print("Response content:", response.text)

except Exception as err:
    print(f"An error occurred: {err}")

I am facing the following error

SSL error occurred: HTTPSConnectionPool(host=”, port=443): Max retries exceeded with url: /b2b/login (Caused by SSLError(SSLError(398, ‘[SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3874)’)))

help me how to resolve this

New contributor

Bayya Rahul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT