cyberflohr / node-red-contrib-google-iot-core

Node-RED module for Google IoT Core MQTT connection
Apache License 2.0
4 stars 10 forks source link

Elliptic keys not usable #6

Open jjamor opened 4 years ago

jjamor commented 4 years ago

We cannot create node with elliptic keys (ES256); it requires RSA keys (but these are heavier for some small devices such as Simatic IOT20xx).

As a workaround, I can patch google-iot-core.js as follows to force usage of ES256 algorithm:

--- google-iot-core.js.orig     2018-01-23 05:24:54.000000000 +0000
+++ google-iot-core.js  2020-02-07 19:13:08.867902125 +0000
@@ -50,7 +50,7 @@
             'exp': Math.round(Date.now() / 1000) + 60 * 60,  // 60 minutes
             'aud': projectId
         };
-        return jwt.sign(token, privateKey, { algorithm: 'RS256' });
+        return jwt.sign(token, privateKey, { algorithm: 'ES256' });
     }

     function MQTTBrokerNode(n) {

However I guess it should be implemented in GUI while editing this node.

jjamor commented 4 years ago

This is fixed in node-red-contrib-google-iot-core-custom-auth fork