I am trying to set up https server on python3, but I could not generate a certificate and a key properly.
That is the server code:
import http.server, ssl
server_address = ('localhost', 4443)
httpd = http.server.HTTPServer(server_address, http.server.SimpleHTTPRequestHandler)
httpd.socket = ssl.wrap_socket(httpd.socket,
server_side=True,
certfile='cert.pem',
keyfile='key.pem',
ssl_version=ssl.PROTOCOL_SSLv23)
httpd.serve_forever()
This is how I generate the certificate:
$ openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout key.pem
I set Common Name to mysite.com
Then I made a record in hosts
file, so that I could resolve my host by name:
127.0.0.1 www.mysite.com
127.0.0.1 mysite.com
And import the certificate to the trusted root CA section in *.pem
and *.crt
formats
But chrome browser keeps showing an error
"ERR_CERT_COMMON_NAME_INVALID", "Subject Alternative Name missing"
Is there something I missed or misunderstood?