mirror of
https://github.com/kawasaki/pyscrlink.git
synced 2026-01-06 03:30:13 +01:00
gencert.py: Generate each users's certificate at scratch_link.py start
The script gencert.sh prepares the certificate for the WSS server. The certificate is stored in the bluepy-scratch-link directory path, and shared by users on the machine. This certificate sharing among users is not handy in case one user prepares bluepy-scratch-link and another user use it, since the latter user may not know where the certificate is. Address this issue by generating the certificate for each user. Re-implement gencert.sh as a python module gencert.py, and integrate it in scratch_link.py. With this, when a user starts scratch_link.py, the certificate unique for the user is generated and stored under user home directory at the path "~/.local/share/blupy-scrach-link". The newly added python module gencert.py depends on pyOpenSSL to generate the certificates. Add this dependency to requirements.txt. Signed-off-by: Shin'ichiro Kawasaki <kawasaki@juno.dti.ne.jp>
This commit is contained in:
@@ -26,6 +26,9 @@ import threading
|
||||
import time
|
||||
import queue
|
||||
|
||||
# for websockets certificate
|
||||
import gencert
|
||||
|
||||
logLevel = logging.INFO
|
||||
|
||||
# handle command line options
|
||||
@@ -642,10 +645,13 @@ class BLESession(Session):
|
||||
self.delegate.restart_notification_event.set()
|
||||
return self.status == self.DONE
|
||||
|
||||
# Prepare certificate of the WSS server
|
||||
gencert.prep_cert()
|
||||
|
||||
# kick start WSS server
|
||||
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||
localhost_cer = pathlib.Path(__file__).with_name("scratch-device-manager.cer")
|
||||
localhost_key = pathlib.Path(__file__).with_name("scratch-device-manager.key")
|
||||
localhost_cer = gencert.cert_file_path
|
||||
localhost_key = gencert.key_file_path
|
||||
ssl_context.load_cert_chain(localhost_cer, localhost_key)
|
||||
sessionTypes = { '/scratch/ble': BLESession, '/scratch/bt': BTSession }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user