Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit a0a9487

Browse files
maxmcdsdroege
authored andcommitted
Add --disable-ssl option to simple-server.py
1 parent ad9b875 commit a0a9487

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

signalling/Dockerfile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,4 @@ RUN pip3 install --user websockets
55
WORKDIR /opt/
66
COPY . /opt/
77

8-
RUN sed -i 's/sslctx.load_cert_chain(chain_pem, keyfile=key_pem)/pass/g' \
9-
./simple-server.py
10-
RUN sed -i 's/ssl=sslctx,//g' \
11-
./simple-server.py
12-
13-
CMD python -u ./simple-server.py
8+
CMD python -u ./simple-server.py --disable-ssl

signalling/simple-server.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
parser.add_argument('--port', default=8443, type=int, help='Port to listen on')
2323
parser.add_argument('--keepalive-timeout', dest='keepalive_timeout', default=30, type=int, help='Timeout for keepalive (in seconds)')
2424
parser.add_argument('--cert-path', default=os.path.dirname(__file__))
25+
parser.add_argument('--disable-ssl', default=False, help='Disable ssl', action='store_true')
2526

2627
options = parser.parse_args(sys.argv[1:])
2728

@@ -239,25 +240,27 @@ async def handler(ws, path):
239240
finally:
240241
await remove_peer(peer_id)
241242

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')
251254

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
261264

262265
print("Listening on https://{}:{}".format(*ADDR_PORT))
263266
# Websocket server

0 commit comments

Comments
 (0)