|
22 | 22 | parser.add_argument('--port', default=8443, type=int, help='Port to listen on')
|
23 | 23 | parser.add_argument('--keepalive-timeout', dest='keepalive_timeout', default=30, type=int, help='Timeout for keepalive (in seconds)')
|
24 | 24 | parser.add_argument('--cert-path', default=os.path.dirname(__file__))
|
| 25 | +parser.add_argument('--disable-ssl', default=False, help='Disable ssl', action='store_true') |
25 | 26 |
|
26 | 27 | options = parser.parse_args(sys.argv[1:])
|
27 | 28 |
|
@@ -239,25 +240,27 @@ async def handler(ws, path):
|
239 | 240 | finally:
|
240 | 241 | await remove_peer(peer_id)
|
241 | 242 |
|
242 |
| -# Create an SSL context to be used by the websocket server |
243 |
| -certpath = options.cert_path |
244 |
| -print('Using TLS with keys in {!r}'.format(certpath)) |
245 |
| -if 'letsencrypt' in certpath: |
246 |
| - chain_pem = os.path.join(certpath, 'fullchain.pem') |
247 |
| - key_pem = os.path.join(certpath, 'privkey.pem') |
248 |
| -else: |
249 |
| - chain_pem = os.path.join(certpath, 'cert.pem') |
250 |
| - key_pem = os.path.join(certpath, 'key.pem') |
| 243 | +sslctx = None |
| 244 | +if not options.disable_ssl: |
| 245 | + # Create an SSL context to be used by the websocket server |
| 246 | + certpath = options.cert_path |
| 247 | + print('Using TLS with keys in {!r}'.format(certpath)) |
| 248 | + if 'letsencrypt' in certpath: |
| 249 | + chain_pem = os.path.join(certpath, 'fullchain.pem') |
| 250 | + key_pem = os.path.join(certpath, 'privkey.pem') |
| 251 | + else: |
| 252 | + chain_pem = os.path.join(certpath, 'cert.pem') |
| 253 | + key_pem = os.path.join(certpath, 'key.pem') |
251 | 254 |
|
252 |
| -sslctx = ssl.create_default_context() |
253 |
| -try: |
254 |
| - sslctx.load_cert_chain(chain_pem, keyfile=key_pem) |
255 |
| -except FileNotFoundError: |
256 |
| - print("Certificates not found, did you run generate_cert.sh?") |
257 |
| - sys.exit(1) |
258 |
| -# FIXME |
259 |
| -sslctx.check_hostname = False |
260 |
| -sslctx.verify_mode = ssl.CERT_NONE |
| 255 | + sslctx = ssl.create_default_context() |
| 256 | + try: |
| 257 | + sslctx.load_cert_chain(chain_pem, keyfile=key_pem) |
| 258 | + except FileNotFoundError: |
| 259 | + print("Certificates not found, did you run generate_cert.sh?") |
| 260 | + sys.exit(1) |
| 261 | + # FIXME |
| 262 | + sslctx.check_hostname = False |
| 263 | + sslctx.verify_mode = ssl.CERT_NONE |
261 | 264 |
|
262 | 265 | print("Listening on https://{}:{}".format(*ADDR_PORT))
|
263 | 266 | # Websocket server
|
|
0 commit comments