https://github.com/destrangis/testserver
Sample test server using SNI
https://github.com/destrangis/testserver
example-code python server ssl
Last synced: about 1 month ago
JSON representation
Sample test server using SNI
- Host: GitHub
- URL: https://github.com/destrangis/testserver
- Owner: destrangis
- License: mit
- Created: 2019-10-08T21:06:30.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-08T21:21:04.000Z (over 6 years ago)
- Last Synced: 2025-01-02T22:18:35.194Z (over 1 year ago)
- Topics: example-code, python, server, ssl
- Language: Python
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
Awesome Lists containing this project
README
This is just an example of using Server Name Indication (SNI) on a HTTP server that chooses a certificate based on the hostname that the client wants to connect to. I wrote it just for illustration.
In order to use it, just generate certificates for hosts 'pantagruel' and 'badabec':
$ . create_certificates
Add the hosts to your /etc/hosts file, so that they can be resolved by a web browser:
127.0.0.1 badabec pantagruel
And then run the program:
$ python3 server.py
Listening on 0.0.0.0:8080
And launch the browser to http://pantagruel:8080 or http://badabec:8080, mind that the browser will complain about the self-signed certificates. Just create an exception for them.
You can also use the 'requests' module:
>>> import requests
>>> resp = requests.get("https://badabec:8080/", verify=False)
>>> resp.text
'All fine\r\n'