Why Renew Certificates?
- Certificates typically have a validity period (e.g., 1 year).
- When expired, OPC UA clients and servers will reject connections.
- Renewing involves generating a new certificate, replacing old files, and restarting Node-RED.
Replacing the Server Certificate
If you’re using thenode-red-contrib-opcua-server module, replace the server certificate as follows:
public.pem— your public certificateprivate.pem— your private key
If you’re running Node-RED as a system service, permissions are especially important to avoid startup errors.
Replacing the Client Certificate
If Node-RED is acting as a client to connect to an OPC UA server (using nodes likenode-red-contrib-opcua-client), it stores its identity certificate in:
Client Certificate Location (Windows)
- Files are in
.pemformat - File names match expectations (
public.pem,private.pem) - Permissions allow Node-RED to read them
Client Certificate Location (Linux)
- Files are in
.pemformat - File names match expectations (
public.pem,private.pem) - Permissions allow Node-RED to read them
Required Certificate Extensions
When generating your certificate, ensure the following X.509 extensions are set to avoid handshake errors:Common Name (CN) and Subject Alternative Name (SAN)
The Common Name (CN) in your certificate must exactly match the hostname used in your OPC UA connection.Example: If your client connects to
opc.tcp://my-server.local:4840, the CN should be my-server.local.Subject Alternative Name (SAN)
Modern clients (including browsers and OPC UA stacks) often require SAN fields. You can include them using OpenSSL config:Generating New Certificates with OpenSSL
Here’s an exampleopenssl.cnf snippet you can use:
Troubleshooting Tips
If you’re running into issues even after replacing the certificates, here are common things to check:- Make sure the CN and SAN match the endpoint host
- Ensure the files are
.pemformat, not.crtor.der - Verify certificate is not expired:
- Check that the certificate has the correct
keyUsageandextendedKeyUsagefields - Ensure correct file permissions so Node-RED can access the certs
- Include the full certificate chain if using a CA-signed certificate (some clients require intermediate + root certs)
Summary Table
Automating Certificate Renewal (Optional)
If you manage multiple environments or frequent testing, consider automating the renewal process: Example Linux script could:- Generate a new certificate via OpenSSL
- Copy it to the appropriate folder(s)
- Restart Node-RED (
systemctl restart nodered.service)
Always validate certificates in a test setup before deploying to production.

