简体   繁体   English

使用PFX证书指纹的HTTPS连接

[英]HTTPS connection using PFX Certificate Thumbprint

I Need to connect into a server using a PFX certificate or PFX certificate thumbprint. 我需要使用PFX证书或PFX证书指纹连接到服务器。

I've trying to find how to connect into my server using a PFX and there is nothing over internet can show me how to do it. 我试图找到如何使用PFX连接到服务器的方法,但互联网上没有任何东西可以向我展示如何做到这一点。

so far what I have is the usage of "requests" library (module), please see what i have so far: 到目前为止,我所使用的是“请求”库(模块)的用法,请参阅到目前为止的内容:

 import requests
 requests.get("https://my.server.com/api/ping")

 output: 
 <Response [403]>

As far as I know, the 403 error code is due to server has rejected the connection, and I can understand that, it needs the certificate in order accept the connection. 据我所知,403错误代码是由于服务器拒绝了连接所致,据我所知,它需要证书才能接受连接。

PFX is also called PKCS#12, so please have a look at the pkcs12 library for requests. PFX也称为PKCS#12,因此请查看pkcs12库以获取请求。

https://pypi.org/project/requests-pkcs12/ https://pypi.org/project/requests-pkcs12/

It adds the necessary parts and pieces to use PFX files instead of PEM files for requests. 它添加了使用PFX文件而不是PEM文件进行请求所必需的部分。

eg 例如

from requests_pkcs12 import get

r = get('https://example.com/test', pkcs12_filename='clientcert.p12',  pkcs12_password='correcthorsebatterystaple')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM