无法验证CA签名的SSL证书python Web服务器

时间:2020-10-15 11:17:08

标签: python ssl https ssl-certificate

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

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

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错误。但是,当我从邮递员设置中禁用SSL certificate verification时,便可以发出请求并获得响应。

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

1 个答案:

答案 0 :(得分:0)

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

我不得不使用cert.pem文件来代替fullchain1.pem文件。

相关问题