update ansible-galaxy testserver to use SSLContext.load_cert_chain (#80961)

* update ansible-galaxy testserver to use SSLContext.load_cert_chain for Python 3.12 compatibility
pull/81149/head
Sloane Hertel 1 year ago committed by GitHub
parent e34807d010
commit 26d855c87e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,20 +1,15 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import sys import http.server
import socketserver
import ssl import ssl
if __name__ == '__main__': if __name__ == '__main__':
if sys.version_info[0] >= 3: Handler = http.server.SimpleHTTPRequestHandler
import http.server context = ssl.SSLContext()
import socketserver context.load_cert_chain(certfile='./cert.pem', keyfile='./key.pem')
Handler = http.server.SimpleHTTPRequestHandler httpd = socketserver.TCPServer(("", 4443), Handler)
httpd = socketserver.TCPServer(("", 4443), Handler) httpd.socket = context.wrap_socket(httpd.socket, server_side=True)
else:
import BaseHTTPServer
import SimpleHTTPServer
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = BaseHTTPServer.HTTPServer(("", 4443), Handler)
httpd.socket = ssl.wrap_socket(httpd.socket, certfile='./cert.pem', keyfile='./key.pem', server_side=True)
httpd.serve_forever() httpd.serve_forever()

Loading…
Cancel
Save