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

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,41 @@ All notable changes to this project are documented here. The format follows
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [1.2.1] - 2026-11-12
10
+
11
+ ### Fixed
12
+
13
+ - `s7 endpoint` editor, *Read from the PLC*: when the check of the deployed endpoint refused the
14
+ PLC certificate, the button showed only the error, so a new PLC certificate could not be taken
15
+ over with *Use this certificate*. It now shows the refused certificate with a warning. `s7 info`
16
+ action `certificate` returns it with `refused: true` and `error`; a trusted certificate has
17
+ `refused: false`.
18
+ - Rust crate `s7plus`: a refused certificate gives `Error::CertificateRefused { reason, cert }`
19
+ (before: `Error::Certificate`, which now means a wrong check setting only) and
20
+ `Error::refused_certificate()`.
21
+
22
+ ## [1.2.0] - 2026-11-12
23
+
24
+ ### Added
25
+
26
+ - `s7 endpoint`: check of the PLC certificate (S7CommPlus with TLS), option "PLC certificate":
27
+ *pinned fingerprint* (SHA-256, one or more) or *trusted certificate or project CA* (PEM: the
28
+ chain, the validity and the name, by default the host; option "Certificate name"). The
29
+ default is no check, as before. When the check fails, the endpoint stays disconnected with
30
+ an error that names the reason and the fingerprint it got. A check without TLS, a bad
31
+ fingerprint or a bad PEM stops the endpoint with a configuration error.
32
+ - `s7 info`: action `certificate` (S7CommPlus with TLS): subject, issuer, validity, alternative
33
+ names, SHA-256 fingerprint, PEM and the check of the endpoint. The editor of the endpoint reads
34
+ it ("Read from the PLC") and copies the fingerprint and the PEM to the fields. Action `info`:
35
+ new fields `certificateCheck`, `certificateFingerprint`.
36
+ - Rust crate `s7plus`: `TlsOptions::verify` (`CertVerify`: `None`, `Fingerprint`, `Trusted`),
37
+ `Error::Certificate` (also for `verify` together with a caller `config`, which has its own
38
+ verifier), `SessionInfo::peer_cert`, a small X.509 reader (`x509::parse`,
39
+ `x509::pem`); the fake PLC can use a certificate signed by a CA (`enable_tls_signed`).
40
+ - `test/plcsim/live_cert.js`: the check against PLCSIM. Tested on PLCSIM Advanced V8 (S7-1500,
41
+ FW S4.1): the PLC certificate is self-signed (CN `PLC-1/Communication-1`, IP address in the
42
+ alternative names, CA:FALSE); both checks accept it, a wrong fingerprint or name is refused.
43
+
9
44
  ## [1.1.0] - 2026-11-12
10
45
 
11
46
  ### Added
@@ -140,7 +175,9 @@ First release: the next generation of `@oriolrius/node-red-contrib-s7`.
140
175
  - CI: tests on Node-RED 4 and 5, gitleaks, GitGuardian, RustSec and npm audit, CodeQL,
141
176
  OpenSSF Scorecard, Dependabot. License LGPL-3.0-only.
142
177
 
143
- [Unreleased]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.1.0...HEAD
178
+ [Unreleased]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.2.1...HEAD
179
+ [1.2.1]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.2.0...v1.2.1
180
+ [1.2.0]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.1.0...v1.2.0
144
181
  [1.1.0]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.0.5...v1.1.0
145
182
  [1.0.5]: https://github.com/oriolrius/node-red-contrib-s7-rust/compare/v1.0.4...v1.0.5
146
183
  [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,21 @@ 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; *Read
192
+ from the PLC* then shows the refused certificate with a warning (`refused: true`), so a new PLC
193
+ certificate can be checked and taken over.
194
+
180
195
  ## Addresses
181
196
 
182
197
  One address per line in the node, or in `msg.tags` / `msg.topic`.
@@ -266,7 +281,8 @@ S7-1200 on the same LAN).
266
281
  - `s7 watch`, mode "PLC subscription": the cycle time is the interval (100 ms or more; S7-1500
267
282
  FW V4.x sends no changes without a cycle time). Each subscription uses one of the PLC
268
283
  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).
284
+ - S7CommPlus: the PLC certificate is not verified by default (TLS then protects against passive
285
+ capture only); set "PLC certificate" in the endpoint. No revocation check (CRL / OCSP).
270
286
 
271
287
  ## Migration from @oriolrius/node-red-contrib-s7
272
288
 
Binary file
Binary file
@@ -13,8 +13,26 @@
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; <i>Read from the
34
+ PLC</i> then shows the refused certificate with a warning (for example after a new PLC
35
+ certificate).</p>
18
36
  <p>Some CPUs accept only TLS sessions (for example PLCSIM Advanced V8, FW S4.1). If the
19
37
  connection fails with "the PLC refused the session without TLS", turn on TLS.</p>
20
38
  <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,19 @@
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
+ "refused": "NOT TRUSTED by the check of the deployed endpoint. Compare it with the certificate in TIA Portal before you use it."
44
+ },
28
45
  "link": {
29
46
  "default": "CPU default",
30
47
  "basic": "S7 Basic / other"
@@ -39,7 +56,8 @@
39
56
  "placeholder": {
40
57
  "default": "default",
41
58
  "username": "empty: legacy password only",
42
- "password": "empty: no legitimation"
59
+ "password": "empty: no legitimation",
60
+ "certName": "empty: the host (IP address or DNS name)"
43
61
  },
44
62
  "hint": {
45
63
  "gap": "merge reads closer than N bytes; -1 = off"
@@ -30,6 +30,11 @@
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>, <code>check</code> (the check
36
+ of the endpoint), and <code>refused</code>: true when the check refused this certificate
37
+ (then <code>error</code> has the reason)</li>
33
38
  <li><code>dbs</code>: data blocks; <code>browse</code>: all symbols with their types</li>
34
39
  <li><code>alarms {all}</code>: active alarms; <code>limits</code>: system limits</li>
35
40
  </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,38 @@
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
+ const warn = c.refused ? `${node._('s7rs-endpoint.cert.refused')}\n${c.error}\n\n` : '';
57
+ out.text(`${warn}${c.subject}\n${node._('s7rs-endpoint.cert.issuer')}: ${c.issuer}\n${c.notBefore} - ${c.notAfter}\n${(c.altNames || []).join(', ')}\nSHA-256 ${c.fingerprint}`);
58
+ out.css('color', c.refused ? 'var(--red-ui-text-color-error, #d00)' : '');
59
+ $('#s7rs-cert-use').show().off('click').on('click', () => {
60
+ $('#node-config-input-certFingerprint').val(c.fingerprint);
61
+ $('#node-config-input-certTrusted').val(c.pem);
62
+ });
63
+ })
64
+ .fail((x) => {
65
+ out.css('color', '');
66
+ out.text((x.responseJSON && x.responseJSON.error) || node._('s7rs-endpoint.cert.notDeployed'));
67
+ $('#s7rs-cert-use').hide();
68
+ });
69
+ });
41
70
  },
42
71
  });
43
72
  </script>
@@ -129,6 +158,32 @@
129
158
  <input type="checkbox" id="node-config-input-tls" style="width: auto; display: inline-block" />
130
159
  <span data-i18n="s7rs-endpoint.label.tls"></span>
131
160
  </div>
161
+ <div class="form-row s7rs-tls">
162
+ <label for="node-config-input-certVerify"><i class="fa fa-certificate"></i> <span data-i18n="s7rs-endpoint.label.certVerify"></span></label>
163
+ <select id="node-config-input-certVerify">
164
+ <option value="none" data-i18n="s7rs-endpoint.certVerify.none"></option>
165
+ <option value="fingerprint" data-i18n="s7rs-endpoint.certVerify.fingerprint"></option>
166
+ <option value="trusted" data-i18n="s7rs-endpoint.certVerify.trusted"></option>
167
+ </select>
168
+ </div>
169
+ <div class="form-row s7rs-cert-fp">
170
+ <label for="node-config-input-certFingerprint" data-i18n="s7rs-endpoint.label.certFingerprint"></label>
171
+ <input type="text" id="node-config-input-certFingerprint" placeholder="AB:9F:2B:..." style="font-family: monospace" />
172
+ </div>
173
+ <div class="form-row s7rs-cert-trusted">
174
+ <label for="node-config-input-certTrusted" data-i18n="s7rs-endpoint.label.certTrusted"></label>
175
+ <textarea id="node-config-input-certTrusted" rows="6" placeholder="-----BEGIN CERTIFICATE-----" style="width: 70%; font-family: monospace; font-size: 11px"></textarea>
176
+ </div>
177
+ <div class="form-row s7rs-cert-trusted">
178
+ <label for="node-config-input-certName" data-i18n="s7rs-endpoint.label.certName"></label>
179
+ <input type="text" id="node-config-input-certName" data-i18n="[placeholder]s7rs-endpoint.placeholder.certName" />
180
+ </div>
181
+ <div class="form-row s7rs-tls">
182
+ <label>&nbsp;</label>
183
+ <button type="button" class="red-ui-button" id="s7rs-cert-read" data-i18n="s7rs-endpoint.cert.read"></button>
184
+ <button type="button" class="red-ui-button" id="s7rs-cert-use" style="display: none" data-i18n="s7rs-endpoint.cert.use"></button>
185
+ <pre id="s7rs-cert-info" style="margin: 6px 0 0 104px; white-space: pre-wrap; font-size: 11px"></pre>
186
+ </div>
132
187
  <div class="form-row s7rs-plus">
133
188
  <label for="node-config-input-username"><i class="fa fa-user"></i> <span data-i18n="s7rs-endpoint.label.username"></span></label>
134
189
  <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.1",
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",