gpt4 book ai didi

php - 验证从 Python 客户端请求获取的 PHP 中的 CA 文件

转载 作者:行者123 更新时间:2023-12-01 04:37:57 30 4
gpt4 key购买 nike

我有一个访问 PHP 服务器的 python 客户端。客户端代码如下:-

import urllib2
response=urllib2.urlopen('https://204.57.7.4/info.php',cafile="cafile.pem")
print response.read()

请注意,我将 CA 文件与 urlopen 一起附加。我想在服务器上验证客户端请求。

现在我将如何访问基于 PHP 的服务器端的 cafile.pem。

最佳答案

您没有将 CA 文件提交到服务器,而是告诉 python http 客户端根据 cafile.pem 检查服务器提供给它的证书

具体来说,来自python's SSL documentation你是:

loading a set of “certification authority” (CA) certificates used to validate other peers’ certificates when verify_mode is other than CERT_NONE

也就是说,您使用 cafile 来验证服务器是否如其所说。服务器永远不会收到该文件,因此它无法使用该文件来验证客户端。

关于php - 验证从 Python 客户端请求获取的 PHP 中的 CA 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31394697/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com