node-opcua-pki is a comprehensive library for managing Public Key Infrastructures (PKI), Certificate Authorities (CA), and OPC UA certificates, offering both a powerful command-line interface (CLI) and a programmatic API. Designed specifically for the node-opcua ecosystem, it provides full lifecycle management for certificates, including support for intermediate CAs, OpenSSL 3.5.x compatibility, and a robust PFX (PKCS#12) toolbox. The current stable version is 6.13.0, with frequent minor and patch releases demonstrating active maintenance and continuous feature development. Key differentiators include its deep integration with OPC UA standards, a rich set of CLI commands for common PKI operations, and specialized features like an in-memory DER/PEM buffer API for `CertificateAuthority` operations and a certificate database for querying issued certificates. It serves as a critical component for securing OPC UA applications.
npm install node-opcua-pkiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use the `node-opcua-pki` CLI to initialize a Public Key Infrastructure and generate a self-signed OPC UA application certificate for development or testing. It includes verification steps.
Review the v6.5.0 release notes and the current API documentation. Update your code to use the officially exported API for PKI management. For example, use `CertificateManager` and `CertificateAuthority` classes.
Upgrade to v6.0.0+ to benefit from security fixes and modern architecture. Review your build configurations and ensure compatibility with the new monorepo structure. Re-test integrations if relying on non-public APIs or file paths.
Ensure OpenSSL is installed on your operating system. For Ubuntu/Debian, use `sudo apt install openssl`. On Windows, it's typically auto-downloaded on first run, but manual installation might be required in some environments. macOS usually has LibreSSL pre-installed.
Familiarize yourself with the new 3-step workflow for intermediate CAs, including `initializeCSR()`, `installCACertificate()`, and `signCACertificateRequest()` as detailed in the release notes. Ensure full certificate chain output is correctly managed.
Verify that OpenSSL is correctly installed and its executable is accessible from your system's PATH. On Linux, try `openssl version` to check its availability. Install it if missing (e.g., `sudo apt install openssl`). For Windows, ensure automatic download was successful or install manually.
For CommonJS, use `const { CertificateManager } = require('node-opcua-pki');`. For ESM (recommended for modern Node.js and TypeScript), use `import { CertificateManager } from 'node-opcua-pki';`. Ensure your project's `package.json` `type` field is set correctly if mixing module systems.Ensure you have correctly initialized your Certificate Authority using `npx node-opcua-pki createCA --root <your_pki_root_folder>`. If the directory exists but is corrupt, consider recreating it or manually restoring the `index.txt` file (though recreation is safer).