繁体   English   中英

Python 发送带有证书、私钥和密码的请求的代码

[英]Python code for sending requests with certificate, private encrypted key and password

我正在尝试从 https 调用中获取响应,该调用在其端安装了证书。 这是我的代码

import requests
import urllib3

urllib3.disable_warnings()

cert_file_path = "/path/output-crt-file-name.crt"
key_file_path = "/path/output-key-file-name.key"
passwd = 'secretpass'
print(passwd)
url = "https://url/to/fetch/response"
params = {"AppID": "xxxx", "Safe": "xxxx", "Folder": "Root",
          "Object": "xxxx"}
cert = (cert_file_path, key_file_path, passwd)
r = requests.get(url, params=params, cert=cert, verify=True )
print(r.text)

抛出错误

由 SSLError('客户端私钥已加密,需要密码'

请建议。

恐怕请求目前不支持使用加密私钥,请参阅https://2.python-requests.org/en/master/user/advanced/#client-side-certificates

本地证书的私钥必须未加密。 目前,Requests 不支持使用加密密钥。

有关如何删除密钥加密的说明,请参阅https://security.stackexchange.com/questions/59136/can-i-add-a-password-to-an-existing-private-key

暂无
暂无

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

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