Skip to content

Commit 1605078

Browse files
committed
TLS: fix loading only the first certificate in chain
1 parent d71493d commit 1605078

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

syncplay/server.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,18 @@ def setPlaylistIndex(self, watcher, index):
250250

251251
def _allowTLSconnections(self, path):
252252
try:
253-
privKey = open(path+'/privkey.pem', 'rt').read()
254-
certif = open(path+'/cert.pem', 'rt').read()
255-
chain = open(path+'/chain.pem', 'rt').read()
253+
privKey = open(path+'/privkey.pem', 'rb').read()
254+
certif = open(path+'/cert.pem', 'rb').read()
255+
chain = open(path+'/chain.pem', 'rb').read()
256256

257257
self.lastEditCertTime = os.path.getmtime(path+'/cert.pem')
258258

259259
privKeyPySSL = crypto.load_privatekey(crypto.FILETYPE_PEM, privKey)
260260
certifPySSL = crypto.load_certificate(crypto.FILETYPE_PEM, certif)
261-
chainPySSL = [crypto.load_certificate(crypto.FILETYPE_PEM, chain)]
261+
262+
sentinel = b'-----BEGIN CERTIFICATE-----'
263+
chainPySSL = [crypto.load_certificate(crypto.FILETYPE_PEM, sentinel + chain_cert) for chain_cert in
264+
chain.split(sentinel)[1:]]
262265

263266
cipherListString = "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:"\
264267
"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:"\

0 commit comments

Comments
 (0)