IMD SolutionComputing LibraryShop main store

How-to

Harden a Node-RED OPC UA server exposing PLC tags

Edge computing and IIoT Published 6 min read

Short answer

A default Node-RED OPC UA server accepts any client that can reach its port until three changes land: set message security mode to SignAndEncrypt with the Basic256Sha256 policy, remove mode None and anonymous login, and admit clients only through application-certificate trust lists. Those three changes are the whole decision; the rest is execution.

On this page
  1. What the default endpoint leaves open
  2. Certificates decide who connects
  3. Lock down the endpoint in order
  4. A worked example: certificate life on the calendar
  5. Prove the endpoint with six tests
  6. Faults you will meet on this gateway
  7. Questions asked

A Node-RED flow that serves PLC tags over OPC UA is not production-ready just because clients can browse and read. Until the endpoint is changed, a default server still offering security mode None with anonymous login accepts any client that can reach its TCP port, and every tag it carries is readable on the wire. Commit to this configuration and nothing weaker: message security mode SignAndEncrypt with the Basic256Sha256 policy, mode None and anonymous login removed, and clients admitted only through application instance certificate trust lists. The steps and tests below deploy exactly that and prove it holds.

What the default endpoint leaves open #

Three layers decide exposure. The message security mode decides whether the channel is signed and encrypted. The security policy decides which cryptographic suite does that work. The user identity token decides who the session acts as once the channel exists.

Endpoint configuration Integrity Confidentiality Client authenticated Decision
Mode None, anonymous No No No Isolated bench host only
Mode Sign Yes No Application certificate Not for PLC tags
Mode SignAndEncrypt Yes Yes Application certificate Production default
Either secure mode plus a username token As the mode gives As the mode gives Adds a user-level check Add on Sign or SignAndEncrypt, never on None

Offer exactly one endpoint: SignAndEncrypt with Basic256Sha256. Remove None from the endpoint list, and disable Basic128Rsa15 and Basic256 where the node lists them, because both policies are deprecated. Require a username token and turn anonymous login off. Where each setting lives depends on the OPC UA server package and its version, so read it from the node's configuration and that package's documentation.

Securing the OPC UA leg does nothing for the leg between the flow's driver node and the PLC: that leg runs the protocol the PLC node speaks, with its own security. Treat them as two trust boundaries, keep the Node-RED host on the controls-network side of any firewall, and expose only the OPC UA listening port toward client networks.

Certificates decide who connects #

The certificate management part of the OPC UA specification, OPC 10000-2, makes each application responsible for a trust list: it accepts secure channels only from applications whose certificates sit on that list. Each side holds an application instance certificate and key pair, and a session fails at the secure-channel step, before any login, when either side does not trust the peer. The published Basic256Sha256 profile defines the algorithms used on the sign and signandencrypt endpoints, and its key and hash minimums apply; a certificate below them fails policy negotiation.

Certificate field Must satisfy Symptom when it does not
ApplicationUri in the Subject Alternative Name Equal the URI the server advertises Client rejects with an application URI mismatch
SAN DNS or IP entry Match the hostname or address clients type Hostname validation failure on strict clients
Validity period Be current at both ends Rejected as expired or not yet valid
Key usage and key size Meet the policy profile Certificate rejected as unsuitable, or negotiation fails

For the trust model, commit like this: with one server, a handful of clients and one engineer keeping the lists current, run a self-signed certificate per server. From about three servers onward, issue from an internal certificate authority and trust that authority on every server and client, so adding a client touches nothing. When the failure sits on the client side of the pair, troubleshooting a client's Basic256Sha256 SignAndEncrypt setup walks the same checks from the other end.

Lock down the endpoint in order #

These steps assume Node-RED already runs on the edge host; installing Node-RED natively on a Linux edge computer is the starting point when it does not.

  1. Fix the host name and static address the server will advertise. Certificates bind to these names, and changing them later forces a reissue.
  2. Point the host clock at NTP or the plant time source. Certificate validity checks fail on a host whose clock is wrong.
  3. Generate the server key pair and certificate with the ApplicationUri in the SAN and the exact hostname or address clients will type. Store the private key readable only by the account that runs Node-RED.
  4. In the server node's configuration, set the message security mode to SignAndEncrypt, select Basic256Sha256, and remove None from the endpoint list.
  5. Create named users with strong, unique credentials and disable anonymous login. Keep credentials out of exported flow files: use Node-RED's credential store or environment variables.
  6. Deploy. The first client connection is rejected by design; confirm that client's certificate thumbprint with its owner, then move the certificate from the server's rejected store into the trusted store.
  7. Import the server's certificate into the client's trust list so the client stops challenging the server's identity at every connect.
  8. Restrict the OPC UA listening port at the host firewall to the known client addresses. Never forward that port through a perimeter firewall to the internet.
  9. If the flow writes back to PLC tags, define an explicit allow-list of writable variables: any writable address-space node hands an authenticated client control authority over the machine.

A Node-RED server is a general-purpose runtime, not a safety device: route no safety function through it.

A worked example: certificate life on the calendar #

The dates here are illustrative; the arithmetic is what transfers. Say the server certificate is issued 2026-05-10 with a 12-month validity. Not-after = 2026-05-10 + 12 months = 2027-05-10, and from that moment session creation fails for every client at once. Renewal belongs earlier: 2027-05-10 - 30 days = 2027-04-10. Calendar the renewal for 2027-04-10 and you hold a 30-day window to issue the successor, place it in the trust lists at both ends, and confirm clients before the old certificate dies. Client certificates on the server's trust list follow the same arithmetic, and an expired trusted client certificate is as fatal as an expired server certificate, so both ends go on one calendar.

Prove the endpoint with six tests #

  1. From a client, read the server's endpoint list with GetEndpoints: only SignAndEncrypt with Basic256Sha256 appears, and no None entry remains.
  2. Attempt a connection with security None and an anonymous identity. The server must refuse it.
  3. Attempt a connection with an untrusted client certificate. It must fail at the secure channel, and the certificate should land in the rejected store.
  4. Connect with the trusted certificate and a valid user, browse, read one tag, and compare the value with the controller's online value.
  5. Capture traffic on the server's network interface during a live subscription: no tag names or values may be readable in the capture.
  6. Attempt a write to a variable that is not on the allow-list. The server must reject it.

Faults you will meet on this gateway #

Symptom Mechanism First check
Client reports an untrusted peer The client certificate is not on the trust list The server's rejected store; compare thumbprints
Client reports no matching endpoint The server does not offer that mode or policy The endpoint list from GetEndpoints
Works by address, fails by hostname, or the reverse The SAN lacks the name the client uses The SAN entries in the certificate
Values go stale while the session stays healthy The PLC polling leg stalled, not the OPC UA leg The driver node's status and the flow's last-update timestamp
Certificates vanish after a move to new hardware Key material was not migrated Back up the certificate store together with the flows

An endpoint that passes all six tests refuses everything except a trusted, authenticated, encrypted client. That is the definition of production-ready for this gateway.

Questions asked

Can I leave mode None enabled for a local test client?

No. Every None endpoint the server offers is a complete read path with no encryption and no client authentication, and a client that shares only that endpoint will negotiate down to it. Do protocol and flow testing on an isolated bench host with no route to the plant network, or run a separate server instance there. The production server offers exactly one endpoint.

When is a self-signed server certificate good enough?

With a single server and a small, stable client list, yes, and it keeps the design honest: every trust decision stays visible in the lists. The cost is distribution. Each new client must be trusted by hand on the server, and each new server means importing another certificate into every client. Once servers multiply or clients change often, an internal certificate authority pays that cost once.

Why did every client drop at the same moment after months of service?

Check the not-after date on the server certificate first: from that date, session creation fails for every client at once. Then check the client certificates on the trust list, which fail the same way when they expire. Check the host clock too, because a wrong clock makes a valid certificate read as expired or not yet valid.

Does SignAndEncrypt also protect the link to the PLC?

No. The secured channel runs between the Node-RED server and its OPC UA clients. The leg from the flow's driver node to the PLC uses whatever protocol that node speaks, with its own security settings, and OPC UA encryption does nothing there. Close that leg with the driver's own mechanisms and network segmentation, and keep the host on the controls-network side of the firewall.

My client only offers Basic256. Should I re-enable it on the server?

No. Update or replace the client instead of reopening a deprecated policy on the server; Basic128Rsa15 and Basic256 are deprecated, and each extra policy widens the endpoint list a weaker client can settle for. If the client genuinely cannot be updated, serve it from a separate isolated instance, never from the production gateway.

Keep reading

  • How-to

    Bridging OPC UA PLC data to MQTT with an edge PC

    Keep the OPC UA server on the PLC side and give MQTT publishing its own role on a separate edge PC that acts as the OPC UA client and MQTT publisher. Commission the two links independently — first a verified tag read, then a verified subscriber message — and only then widen the tag set.

    Edge computing and IIoT

  • How-to

    Sending PLC data to an IoT hub without custom software

    You do not need custom software to move PLC data to an IoT hub: a configurable edge package with an S7, Modbus TCP or EtherNet/IP driver, a channel mapping and an MQTT publisher replaces hand-written acquisition code. Verify two things before you commit: the driver covers the protocol your controller actually speaks, and the publisher covers the destination's authentication and message format. Software still does the work — you configure it instead of writing it.

    Edge computing and IIoT

  • How-to

    Deploying Edge Data Store in Docker on a controller PC

    Run Edge Data Store as a Docker container on the controller-class edge PC and let its OPC UA adapter ingest the local server over localhost. Define egress targets, buffering and forwarding schedules in the JSON configuration, size the buffer from tag count, scan rate and outage target—50 tags at 1 event/s across an 8-hour outage is about 288 MB—and sign off only after a live pulled-cable test.

    Edge computing and IIoT