{"library":"node-opcua-crypto","title":"Node-OPCUA Crypto Tools","description":"Node-OPCUA Crypto is a robust, TypeScript-first JavaScript module designed to provide a comprehensive suite of cryptographic functionalities specifically for the OPC UA standard. It seamlessly operates in both Node.js and browser environments, ensuring broad compatibility for various industrial IoT and M2M applications. The library is currently on its stable version 5.3.5, with recent releases, such as v5.2.0, focusing on critical improvements like dependency reduction, enhanced browser compatibility, and the introduction of new cryptographic utilities including CRL-to-issuer matching. Key differentiators include its deep integration with OPC UA security requirements, support for generating private keys and X.509 self-signed certificates using native WebCrypto APIs, and dual CommonJS/ESM module support since version 3.0.0. This makes it a foundational component for securing OPC UA communications, offering tools for certificate management, key generation, and compliance with modern cryptographic practices. The project maintains an active release cadence, addressing bugs and introducing features regularly.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-opcua-crypto"],"cli":null},"imports":["import { generatePrivateKey } from 'node-opcua-crypto';","import { createSelfSignedCertificate, CertificatePurpose } from 'node-opcua-crypto';","import * as crypto from 'node-opcua-crypto';","import { identifyDERContent } from 'node-opcua-crypto/dist/identify_der';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { generatePrivateKey, privateKeyToPEM, CertificatePurpose, createSelfSignedCertificate } from 'node-opcua-crypto';\n\nasync function demonstratePrivateKeyAndSelfSignedCertificateCreation() {\n    // Create a new private key\n    const privateKey = await generatePrivateKey();\n\n    // Convert the private key to a PEM format for storage or display\n    const { privPem } = await privateKeyToPEM(privateKey);\n\n    console.log('Generated Private Key (PEM format):\\n', privPem);\n\n    // Create a self-signed X.509 certificate\n    const { cert } = await createSelfSignedCertificate({\n        privateKey,\n        notAfter: new Date(Date.now() + 365 * 24 * 60 * 60 * 1000), // Valid for 1 year from now\n        notBefore: new Date(),\n        subject: 'CN=Test Server, O=MyCompany, L=City, ST=State, C=US',\n        dns: ['localhost', 'my-server.example.com'],\n        ip: ['127.0.0.1'],\n        applicationUri: 'urn:TestServer:MyApplication',\n        purpose: CertificatePurpose.ForApplication\n    });\n    console.log('\\nGenerated Self-Signed Certificate (PEM format):\\n', cert);\n}\n\ndemonstratePrivateKeyAndSelfSignedCertificateCreation().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to generate a private key and then use it to create a self-signed X.509 certificate, common for OPC UA server and client identities.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}