admin管理员组

文章数量:1122832

I have a webservice that requires a client certificate for authentication. I want to access this webservice using HTTPX (Python), but I don't see how to make this work with my p12 certificate store. It seems that HTTPX needs the certificate file, the privatekey file and the password. Is there no way to directly use the p12 file?

I would like to pass the filepath to the p12 file (or its binary content) plus the password to HTTPX

I have a webservice that requires a client certificate for authentication. I want to access this webservice using HTTPX (Python), but I don't see how to make this work with my p12 certificate store. It seems that HTTPX needs the certificate file, the privatekey file and the password. Is there no way to directly use the p12 file?

I would like to pass the filepath to the p12 file (or its binary content) plus the password to HTTPX

Share Improve this question asked Nov 22, 2024 at 17:42 Tom ArnTom Arn 1
Add a comment  | 

2 Answers 2

Reset to default 0

HTTPX does not directly support loading PKCS12 (.p12) files, but you can use the cryptography library to extract the necessary key and certificate from the PKCS12 file and then pass them to HTTPX

  • Extract certificate and private keys from pkcs12 store
  • Install certifi package
  • Add pem certificates to python's certificates

cat /home/lmc/projects/lmc-local.cert.pem >> /home/lmc/.local/lib/python3.11/site-packages/certifi/cacert.pem

From the docs

By default, HTTPX uses the CA bundle provided by Certifi.

本文标签: pythonHow to use a PCKS12 file with HTTPXStack Overflow