node-red-contrib-s7-rust 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,28 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.0] - 2026-11-12
10
+
11
+ ### Added
12
+
13
+ - `s7 endpoint`: check of the PLC certificate (S7CommPlus with TLS), option "PLC certificate":
14
+ *pinned fingerprint* (SHA-256, one or more) or *trusted certificate or project CA* (PEM: the
15
+ chain, the validity and the name, by default the host; option "Certificate name"). The
16
+ default is no check, as before. When the check fails, the endpoint stays disconnected with
17
+ an error that names the reason and the fingerprint it got. A check without TLS, a bad
18
+ fingerprint or a bad PEM stops the endpoint with a configuration error.
19
+ - `s7 info`: action `certificate` (S7CommPlus with TLS): subject, issuer, validity, alternative
20
+ names, SHA-256 fingerprint, PEM and the check of the endpoint. The editor of the endpoint reads
21
+ it ("Read from the PLC") and copies the fingerprint and the PEM to the fields. Action `info`:
22
+ new fields `certificateCheck`, `certificateFingerprint`.
23
+ - Rust crate `s7plus`: `TlsOptions::verify` (`CertVerify`: `None`, `Fingerprint`, `Trusted`),
24
+ `Error::Certificate` (also for `verify` together with a caller `config`, which has its own
25
+ verifier), `SessionInfo::peer_cert`, a small X.509 reader (`x509::parse`,
26
+ `x509::pem`); the fake PLC can use a certificate signed by a CA (`enable_tls_signed`).
27
+ - `test/plcsim/live_cert.js`: the check against PLCSIM. Tested on PLCSIM Advanced V8 (S7-1500,
28
+ FW S4.1): the PLC certificate is self-signed (CN `PLC-1/Communication-1`, IP address in the
29
+ alternative names, CA:FALSE); both checks accept it, a wrong fingerprint or name is refused.
30
+
9
31
  ## [1.1.0] - 2026-11-12
10
32
 
11
33
  ### Added
@@ -140,7 +162,8 @@ First release: the next generation of `@oriolrius/node-red-contrib-s7`.
140
162
  - CI: tests on Node-RED 4 and 5, gitleaks, GitGuardian, RustSec and npm audit, CodeQL,
141
163
  OpenSSF Scorecard, Dependabot. License LGPL-3.0-only.
142
164
 
143
- [Unreleased]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.1.0...HEAD
165
+ [Unreleased]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.2.0...HEAD
166
+ [1.2.0]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.1.0...v1.2.0
144
167
  [1.1.0]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.0.5...v1.1.0
145
168
  [1.0.5]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.0.4...v1.0.5
146
169
  [1.0.4]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.0.3...v1.0.4
package/README.md CHANGED
@@ -79,12 +79,12 @@ Then restart Node-RED. The nodes are in the **network** category of the palette.
79
79
 
80
80
  | Node | Function |
81
81
  |---|---|
82
- | `s7 endpoint` (config) | One PLC connection: protocol, host, port. S7comm: CPU family, rack/slot or TSAPs, PDU, gap, byte order. S7CommPlus: remote TSAP, TLS, user, password (stored as a credential). |
82
+ | `s7 endpoint` (config) | One PLC connection: protocol, host, port. S7comm: CPU family, rack/slot or TSAPs, PDU, gap, byte order. S7CommPlus: remote TSAP, TLS and the check of the PLC certificate, user, password (stored as a credential). |
83
83
  | `s7 read` | Reads tags when a message arrives. Output: one value, `{tag: value}` or an array. |
84
84
  | `s7 write` | Writes the tag of the node, the tag in `msg.topic`, or `msg.payload = {tag: value, …}` in one request. |
85
85
  | `s7 watch` | Sends only the changes. Mode "read cyclically": a Rust thread reads the tags at an interval, with an optional conditional rate ("Fast while" a tag is true). Mode "PLC subscription" (S7CommPlus): the PLC sends the changes. |
86
86
  | `s7 alarms` | S7CommPlus: a message when a PLC alarm comes or goes (alarm subscription; the active alarms at start). |
87
- | `s7 info` | Diagnostics. Both protocols: `status`, `cpuState`. S7comm: `identify`, `szl`, `szlList`, `clock`, `setClock`, `syncClock`, `blocks`, `listBlocks`, `blockInfo`. S7CommPlus: `info`, `dbs`, `browse`, `alarms`, `limits`. |
87
+ | `s7 info` | Diagnostics. Both protocols: `status`, `cpuState`. S7comm: `identify`, `szl`, `szlList`, `clock`, `setClock`, `syncClock`, `blocks`, `listBlocks`, `blockInfo`. S7CommPlus: `info`, `certificate`, `dbs`, `browse`, `alarms`, `limits`. |
88
88
 
89
89
  Every node has full help in the editor sidebar. Bad tags never stop the other tags: they give
90
90
  `null` and an entry in `msg.s7.errors`, or `msg.quality = "bad"` in a watch.
@@ -141,7 +141,7 @@ This map shows each protocol function and where it is available. It is strict: a
141
141
  | Connection | TPKT + COTP, remote TSAP `SIMATIC-ROOT-HMI`, protocol version 1 for the session creation, version 2 after it | ✅ | `s7 endpoint` |
142
142
  | Session | CreateObject 0x04CA (ClientSession), session setup with SetMultiVariables, DeleteObject 0x04D4 at close | ✅ | `s7 endpoint` |
143
143
  | TLS 1.3 | InitSsl 0x05B3, TLS inside COTP | ✅ | `s7 endpoint` (option "TLS") |
144
- | PLC certificate verification | — | ❌ | — (TLS protects against passive capture only) |
144
+ | PLC certificate verification | pinned SHA-256 fingerprint, or chain to a trusted certificate (the PLC certificate or the TIA project CA) with validity and name (IP address or DNS name) | ✅ | `s7 endpoint` (option "PLC certificate"), `s7 info`: `certificate` |
145
145
  | Legitimation (access level password) | challenge from GetVarSubStreamed 0x0586, legacy and new response | ✅ | `s7 endpoint` (password) |
146
146
  | Read | GetMultiVariables 0x054C, symbolic and absolute addresses | ✅ | `s7 read`, `s7 watch` |
147
147
  | Write | SetMultiVariables 0x0542, symbolic and absolute addresses | ✅ | `s7 write` |
@@ -177,6 +177,19 @@ Some CPUs accept only TLS sessions (PLCSIM Advanced V8 with FW S4.1, or a CPU wi
177
177
  secure PG/PC and HMI communication"): without TLS the connection fails with "the PLC refused the
178
178
  session without TLS". Turn on TLS in the endpoint.
179
179
 
180
+ **PLC certificate**: without a check, TLS protects only against passive capture (a device between
181
+ Node-RED and the PLC can show its own certificate). In the endpoint, set "PLC certificate" to:
182
+
183
+ - *pinned fingerprint*: the SHA-256 of the PLC certificate (more than one, separated by commas,
184
+ for a change of certificate);
185
+ - *trusted certificate or project CA*: the PLC certificate in PEM, exported from TIA Portal, or
186
+ the CA of the project. The certificate must be valid now and contain the host (the S7-1500
187
+ puts its IP addresses in it); set "Certificate name" when Node-RED uses another address.
188
+
189
+ *Read from the PLC* in the endpoint editor (or `s7 info` action `certificate`) shows the
190
+ certificate of the deployed endpoint: compare it with TIA Portal before you trust it. When the
191
+ check fails, the endpoint stays disconnected and the error shows the fingerprint it got.
192
+
180
193
  ## Addresses
181
194
 
182
195
  One address per line in the node, or in `msg.tags` / `msg.topic`.
@@ -266,7 +279,8 @@ S7-1200 on the same LAN).
266
279
  - `s7 watch`, mode "PLC subscription": the cycle time is the interval (100 ms or more; S7-1500
267
280
  FW V4.x sends no changes without a cycle time). Each subscription uses one of the PLC
268
281
  subscription resources (`s7 info` → `limits`); when the PLC refuses it, the node reads cyclically.
269
- - S7CommPlus: the PLC certificate is not verified (TLS protects against passive capture only).
282
+ - S7CommPlus: the PLC certificate is not verified by default (TLS then protects against passive
283
+ capture only); set "PLC certificate" in the endpoint. No revocation check (CRL / OCSP).
270
284
 
271
285
  ## Migration from @oriolrius/node-red-contrib-s7
272
286
 
Binary file
Binary file
@@ -13,8 +13,24 @@
13
13
  (S7-300: slot 2; S7-1200/1500: slot 1). With TSAPs set, rack and slot are not used.</p>
14
14
  <p>Gap: tags in the same area and DB that are closer than N bytes are read as one block.</p>
15
15
  <h4>S7CommPlus</h4>
16
- <p>Symbols are resolved once per session (a reconnect resolves them again). The PLC
17
- certificate is not verified. The password is stored as a Node-RED credential.</p>
16
+ <p>Symbols are resolved once per session (a reconnect resolves them again). The password is
17
+ stored as a Node-RED credential.</p>
18
+ <h4>PLC certificate (TLS)</h4>
19
+ <p>Without a check, TLS protects only against passive capture: a device between Node-RED and
20
+ the PLC can show its own certificate. Set one of these checks:</p>
21
+ <ul>
22
+ <li><b>pinned fingerprint</b>: the SHA-256 of the PLC certificate. More fingerprints,
23
+ separated by commas, allow a change of the certificate.</li>
24
+ <li><b>trusted certificate or project CA</b>: the PLC certificate in PEM (exported from
25
+ TIA Portal: device configuration, Protection &amp; Security, certificate manager), or the
26
+ CA of the project when the project CA signs the PLC certificates. The certificate must be
27
+ valid now and contain the certificate name: by default the host (the S7-1500 puts its IP
28
+ addresses in the certificate). Set the name when Node-RED uses another address (NAT).</li>
29
+ </ul>
30
+ <p><i>Read from the PLC</i> shows the certificate of the deployed endpoint, and
31
+ <i>Use this certificate</i> copies its fingerprint and PEM to the fields. Compare it with the
32
+ certificate in TIA Portal before you trust it. When the check fails, the endpoint stays
33
+ disconnected and the error shows the fingerprint of the certificate it got.</p>
18
34
  <p>Some CPUs accept only TLS sessions (for example PLCSIM Advanced V8, FW S4.1). If the
19
35
  connection fails with "the PLC refused the session without TLS", turn on TLS.</p>
20
36
  <h4>Log</h4>
@@ -17,6 +17,10 @@
17
17
  "byteOrder": "Byte order",
18
18
  "remoteTsap": "Remote TSAP",
19
19
  "tls": "TLS 1.3 (S7-1500 ≥ V2.9, S7-1200 ≥ V4.5)",
20
+ "certVerify": "PLC certificate",
21
+ "certFingerprint": "SHA-256",
22
+ "certTrusted": "Trusted (PEM)",
23
+ "certName": "Certificate name",
20
24
  "username": "User",
21
25
  "password": "Password",
22
26
  "logLevel": "Log"
@@ -25,6 +29,18 @@
25
29
  "s7": "S7comm (classic, PUT/GET)",
26
30
  "s7plus": "S7CommPlus (S7-1200/1500, symbols)"
27
31
  },
32
+ "certVerify": {
33
+ "none": "not checked",
34
+ "fingerprint": "pinned fingerprint (SHA-256)",
35
+ "trusted": "trusted certificate or project CA (PEM)"
36
+ },
37
+ "cert": {
38
+ "read": "Read from the PLC",
39
+ "use": "Use this certificate",
40
+ "reading": "reading…",
41
+ "issuer": "issuer",
42
+ "notDeployed": "deploy the endpoint with TLS first"
43
+ },
28
44
  "link": {
29
45
  "default": "CPU default",
30
46
  "basic": "S7 Basic / other"
@@ -39,7 +55,8 @@
39
55
  "placeholder": {
40
56
  "default": "default",
41
57
  "username": "empty: legacy password only",
42
- "password": "empty: no legitimation"
58
+ "password": "empty: no legitimation",
59
+ "certName": "empty: the host (IP address or DNS name)"
43
60
  },
44
61
  "hint": {
45
62
  "gap": "merge reads closer than N bytes; -1 = off"
@@ -30,6 +30,10 @@
30
30
  <h4>S7CommPlus</h4>
31
31
  <ul>
32
32
  <li><code>info</code>: session, PAOM string, limits</li>
33
+ <li><code>certificate</code>: the PLC certificate of the TLS session: <code>subject</code>,
34
+ <code>issuer</code>, <code>notBefore</code>, <code>notAfter</code>, <code>altNames</code>,
35
+ <code>fingerprint</code> (SHA-256), <code>pem</code>, and <code>check</code> (the check
36
+ of the endpoint)</li>
33
37
  <li><code>dbs</code>: data blocks; <code>browse</code>: all symbols with their types</li>
34
38
  <li><code>alarms {all}</code>: active alarms; <code>limits</code>: system limits</li>
35
39
  </ul>
@@ -21,6 +21,10 @@
21
21
  logLevel: { value: 'warn' },
22
22
  tsap: { value: 'SIMATIC-ROOT-HMI' },
23
23
  tls: { value: false },
24
+ certVerify: { value: 'none' },
25
+ certFingerprint: { value: '' },
26
+ certTrusted: { value: '' },
27
+ certName: { value: '' },
24
28
  username: { value: '' },
25
29
  },
26
30
  credentials: {
@@ -31,13 +35,35 @@
31
35
  return this.name || (this.host ? `${p} ${this.host}:${this.port || 102}` : 's7 endpoint');
32
36
  },
33
37
  oneditprepare: function () {
38
+ const node = this;
34
39
  const sync = () => {
35
40
  const plus = $('#node-config-input-protocol').val() === 's7plus';
41
+ const tls = plus && $('#node-config-input-tls').prop('checked');
42
+ const v = $('#node-config-input-certVerify').val();
36
43
  $('.s7rs-classic').toggle(!plus);
37
44
  $('.s7rs-plus').toggle(plus);
45
+ $('.s7rs-tls').toggle(tls);
46
+ $('.s7rs-cert-fp').toggle(tls && v === 'fingerprint');
47
+ $('.s7rs-cert-trusted').toggle(tls && v === 'trusted');
38
48
  };
39
- $('#node-config-input-protocol').on('change', sync);
49
+ $('#node-config-input-protocol, #node-config-input-tls, #node-config-input-certVerify').on('change', sync);
40
50
  sync();
51
+ // reads the certificate of the deployed endpoint (the user checks it before trusting it)
52
+ $('#s7rs-cert-read').on('click', () => {
53
+ const out = $('#s7rs-cert-info').text(node._('s7rs-endpoint.cert.reading'));
54
+ $.getJSON(`s7rs/call/${encodeURIComponent(node.id)}/certificate`)
55
+ .done((c) => {
56
+ out.text(`${c.subject}\n${node._('s7rs-endpoint.cert.issuer')}: ${c.issuer}\n${c.notBefore} - ${c.notAfter}\n${(c.altNames || []).join(', ')}\nSHA-256 ${c.fingerprint}`);
57
+ $('#s7rs-cert-use').show().off('click').on('click', () => {
58
+ $('#node-config-input-certFingerprint').val(c.fingerprint);
59
+ $('#node-config-input-certTrusted').val(c.pem);
60
+ });
61
+ })
62
+ .fail((x) => {
63
+ out.text((x.responseJSON && x.responseJSON.error) || node._('s7rs-endpoint.cert.notDeployed'));
64
+ $('#s7rs-cert-use').hide();
65
+ });
66
+ });
41
67
  },
42
68
  });
43
69
  </script>
@@ -129,6 +155,32 @@
129
155
  <input type="checkbox" id="node-config-input-tls" style="width: auto; display: inline-block" />
130
156
  <span data-i18n="s7rs-endpoint.label.tls"></span>
131
157
  </div>
158
+ <div class="form-row s7rs-tls">
159
+ <label for="node-config-input-certVerify"><i class="fa fa-certificate"></i> <span data-i18n="s7rs-endpoint.label.certVerify"></span></label>
160
+ <select id="node-config-input-certVerify">
161
+ <option value="none" data-i18n="s7rs-endpoint.certVerify.none"></option>
162
+ <option value="fingerprint" data-i18n="s7rs-endpoint.certVerify.fingerprint"></option>
163
+ <option value="trusted" data-i18n="s7rs-endpoint.certVerify.trusted"></option>
164
+ </select>
165
+ </div>
166
+ <div class="form-row s7rs-cert-fp">
167
+ <label for="node-config-input-certFingerprint" data-i18n="s7rs-endpoint.label.certFingerprint"></label>
168
+ <input type="text" id="node-config-input-certFingerprint" placeholder="AB:9F:2B:..." style="font-family: monospace" />
169
+ </div>
170
+ <div class="form-row s7rs-cert-trusted">
171
+ <label for="node-config-input-certTrusted" data-i18n="s7rs-endpoint.label.certTrusted"></label>
172
+ <textarea id="node-config-input-certTrusted" rows="6" placeholder="-----BEGIN CERTIFICATE-----" style="width: 70%; font-family: monospace; font-size: 11px"></textarea>
173
+ </div>
174
+ <div class="form-row s7rs-cert-trusted">
175
+ <label for="node-config-input-certName" data-i18n="s7rs-endpoint.label.certName"></label>
176
+ <input type="text" id="node-config-input-certName" data-i18n="[placeholder]s7rs-endpoint.placeholder.certName" />
177
+ </div>
178
+ <div class="form-row s7rs-tls">
179
+ <label>&nbsp;</label>
180
+ <button type="button" class="red-ui-button" id="s7rs-cert-read" data-i18n="s7rs-endpoint.cert.read"></button>
181
+ <button type="button" class="red-ui-button" id="s7rs-cert-use" style="display: none" data-i18n="s7rs-endpoint.cert.use"></button>
182
+ <pre id="s7rs-cert-info" style="margin: 6px 0 0 104px; white-space: pre-wrap; font-size: 11px"></pre>
183
+ </div>
132
184
  <div class="form-row s7rs-plus">
133
185
  <label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="s7rs-endpoint.label.username"></span></label>
134
186
  <input type="text" id="node-config-input-username" data-i18n="[placeholder]s7rs-endpoint.placeholder.username" />
@@ -9,7 +9,7 @@ const { text, intOrUndef } = require('../lib/common');
9
9
  // Diagnostics the editor may call through the admin API (read-only actions).
10
10
  const ADMIN_ACTIONS = new Set([
11
11
  'identify', 'cpuState', 'szl', 'szlList', 'clock', 'blocks', 'listBlocks', 'blockInfo',
12
- 'info', 'limits', 'dbs', 'browse', 'alarms',
12
+ 'info', 'certificate', 'limits', 'dbs', 'browse', 'alarms',
13
13
  ]);
14
14
 
15
15
  module.exports = function (RED) {
@@ -46,6 +46,10 @@ module.exports = function (RED) {
46
46
  logLevel: config.logLevel || 'warn',
47
47
  tsap: config.tsap || '',
48
48
  tls: config.tls === true || config.tls === 'true',
49
+ certVerify: config.certVerify || 'none',
50
+ certFingerprint: config.certFingerprint || '',
51
+ certTrusted: config.certTrusted || '',
52
+ certName: String(config.certName || '').trim(),
49
53
  username: config.username || '',
50
54
  password: creds.password || '',
51
55
  host: String(config.host || '').trim(),
@@ -58,6 +58,7 @@
58
58
  </optgroup>
59
59
  <optgroup label="S7CommPlus">
60
60
  <option value="info">info</option>
61
+ <option value="certificate">certificate (TLS)</option>
61
62
  <option value="dbs">dbs</option>
62
63
  <option value="browse">browse</option>
63
64
  <option value="alarms">alarms {all}</option>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-s7-rust",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Siemens S7 nodes for Node-RED: S7comm and S7CommPlus (S7-1200/1500 symbolic access) clients written in Rust, running in-process (Node-API). Linux x64.",
5
5
  "keywords": [
6
6
  "node-red",