【问题标题】:Unable to verify the CA signed SSL certificate python web server无法验证 CA 签署的 SSL 证书 python web 服务器
【发布时间】:2021-01-29 20:50:43
【问题描述】:

这是我的 python web 服务器的示例代码:

Python 网络服务器代码(非完整版)

class LogRequests(BaseHTTPRequestHandler):

    def do_GET(self):
        print("GET request received from {}".format(self.client_address[0]))
        self.write_response(200, {"success": True})

    def do_POST(self):
        print("GET request received from {}".format(self.client_address[0]))
        self.write_response(200, {"success": True})

    def write_response(self, status_code, json_body):
        self.send_response(status_code)
        self.send_header('Content-type', 'application/json')
        self.end_headers()
        self.write_json(json_body)


server = HTTPServer(('', 6000), LogRequests)

server.socket = ssl.wrap_socket(server.socket, keyfile=<key-file-path>, certfile=<cert-file-path>, server_side=True)
server.serve_forever()

我有 CA(让我们加密)签名证书。我还用https://support.acquia.com/hc/en-us/articles/360004119234-Verifying-the-validity-of-an-SSL-certificate 验证了 cert.pem 和 key.pem 文件的有效性。

邮递员请求

URL: https://<hostname>:6000/

当我提交 POST 或 GET 请求时,它显示 SSL Error: Unable to verify the first certificate 错误。但是当我从 Postman 设置中禁用 SSL certificate verification 时,我可以发出请求并获得响应。

你能指导我这里有什么问题吗?有代码问题吗?

【问题讨论】:

    标签: python ssl https ssl-certificate


    【解决方案1】:

    我必须自己找到解决方案。

    我不得不使用fullchain1.pem 文件而不是cert.pem 文件。

    【讨论】:

      猜你喜欢
      • 2015-06-24
      • 2016-11-24
      • 1970-01-01
      • 2018-03-20
      • 2013-07-23
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      相关资源
      最近更新 更多