📜  ssl 服务器 python 代码示例

📅  最后修改于: 2022-03-11 14:45:23.258000             🧑  作者: Mango

代码示例1
1. openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
2. Use the Code

import BaseHTTPServer, SimpleHTTPServer
import ssl

httpd = BaseHTTPServer.HTTPServer(('localhost', 4443), SimpleHTTPServer.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True) # Generate the CRT File by OPENSSL.
httpd.serve_forever()