--- a/PSKManagement.py Tue Mar 04 14:19:29 2025 +0100
+++ b/PSKManagement.py Tue Mar 04 17:20:26 2025 +0100
@@ -5,9 +5,13 @@
from __future__ import absolute_import
+from os.path import join, exists from zipfile import ZipFile
+from binascii import b2a_base64 +from util.paths import AppDataPath # PSK Management Data model :
# [[ID,Desc, LastKnownURI, LastConnect]]
@@ -166,3 +170,25 @@
SaveData(project_path, data)
+ own_keystore = AppDataPath("keystore", "own") + if not exists(own_keystore): + os.makedirs(own_keystore) + own_identity = join(own_keystore, "default.psk") + if exists(own_identity): + ID, _sep, PSK = open(own_identity).read().partition(':') + secretstring = PSK.rstrip('\n\r') + ID = os.urandom(8).hex() + # secret string length is 256 + # b2a_base64 output len is 4/3 input len + secret = os.urandom(192) # int(256/1.3333) + secretstring = b2a_base64(secret).decode() + PSKstring = ID+":"+secretstring + with open(own_identity, 'w') as f: + return ID, secretstring --- a/connectors/WAMP/__init__.py Tue Mar 04 14:19:29 2025 +0100
+++ b/connectors/WAMP/__init__.py Tue Mar 04 17:20:26 2025 +0100
@@ -53,7 +53,7 @@
class WampSession(wamp.ApplicationSession):
- user = self.config.extra["ID"]
+ user = self.config.extra["IDE_ID"] self.join(self.config.realm, ["wampcra"], user)
def onChallenge(self, challenge):
@@ -78,7 +78,7 @@
- print('WAMP session joined for :', self.config.extra["ID"])
+ print('WAMP session joined for :', self.config.extra["IDE_ID"]) def onLeave(self, details):
@@ -88,17 +88,18 @@
def _WAMP_connector_factory(cls, uri, confnodesroot):
- WAMP://127.0.0.1:12345/path#realm#ID
- WAMPS://127.0.0.1:12345/path#realm#ID
+ WAMP://127.0.0.1:12345/path#realm#PLC_ID + WAMPS://127.0.0.1:12345/path#realm#PLC_ID scheme, location = uri.split("://")
- urlpath, realm, ID = location.split('#')
+ urlpath, realm, PLC_ID = location.split('#') urlprefix = {"WAMP": "ws",
url = urlprefix+"://"+urlpath
CN = urlpath.split("/")[0].split(":")[0]
- secret = PSK.GetSecret(confnodesroot.ProjectPath, ID)
+ IDE_ID, secret = PSK.GetIDEIdentity() trust_store = Cert.GetCertPath(confnodesroot.ProjectPath, CN)
confnodesroot.logger.write_error(
@@ -115,7 +116,7 @@
component_config = types.ComponentConfig(
session_factory = wamp.ApplicationSessionFactory(
--- a/util/paths.py Tue Mar 04 14:19:29 2025 +0100
+++ b/util/paths.py Tue Mar 04 17:20:26 2025 +0100
@@ -55,3 +55,17 @@
return os.path.join(AbsParentDir(__file__, 2), name, *suffixes)
+ Return path of files in Beremiz project + return os.path.join(AbsParentDir(__file__, 1), *names) +def AppDataPath(*names): + Return path of files in Beremiz project + return os.path.join(os.environ["HOME"], ".local", "share", "beremiz", *names) + return os.path.join(os.environ["APPDATA"], "Beremiz", *names)