【发布时间】: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