UNPKG

6.64 kBMarkdownView Raw
1# node-opcua-crypto
2
3NodeOPCUA Crypto is a powerful JavaScript module for handling security and cryptography for OPCUA. It's written in TypeScript and runs smoothly on Node.js and in the browser.
4
5[![NPM download](https://img.shields.io/npm/dm/node-opcua-crypto.svg)](https://www.npmtrends.com/node-opcua-crypto)
6[![NPM version](https://img.shields.io/npm/v/node-opcua-crypto)](https://www.npmjs.com/package/node-opcua-crypto?activeTab=versions)
7[![Build Status](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml/badge.svg)](https://github.com/node-opcua/node-opcua-crypto/actions/workflows/main.yml)
8[![Code Climate](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/gpa.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto)
9[![Coverage Status](https://coveralls.io/repos/github/node-opcua/node-opcua-crypto/badge.svg?branch=master)](https://coveralls.io/github/node-opcua/node-opcua-crypto?branch=master)
10[![install size](https://packagephobia.com/badge?p=node-opcua-crypto)](https://packagephobia.com/result?p=node-opcua-crypto)
11[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto.svg?type=shield)](https://app.fossa.com/projects/custom%2B20248%2Fgithub.com%2Fnode-opcua%2Fnode-opcua-crypto?ref=badge_shield)
12<!-- [![Test Coverage](https://codeclimate.com/github/node-opcua/node-opcua-crypto/badges/coverage.svg)](https://codeclimate.com/github/node-opcua/node-opcua-crypto/coverage) -->
13
14## Features
15
16* a comprehensive set of cryptographic functionalities.
17* supports both Node.js and browser environments.
18* compatible with TypeScript for robust, type-safe coding.
19* implements advanced security standards for OPCUA.
20
21## Getting Started
22
23To use NodeOPCUA Crypto in your project, follow these steps:
24
25#### Installation
26
27``` bash
28npm install nodeopcua-crypto
29```
30
31### Usage
32
33``` bash
34
35import { generatePrivateKey, privateKeyToPEM, CertificatePurpose, createSelfSignedCertificate } from "./node-opcua-crypto.js";
36
37async function demonstratePrivateKeyAndSelfSignedCertificateCreation() {
38
39 // create the Private Key
40 const privateKey = await generatePrivateKey();
41
42 // convert the private key to a PEM format
43 const { privPem } = await privateKeyToPEM(privateKey);
44
45 console.log(privPem);
46
47 // create a self-sign certificate
48 const { cert } = await createSelfSignedCertificate({
49 privateKey,
50 notAfter: new Date(2025, 1, 1),
51 notBefore: new Date(2019, 1, 1),
52 subject: "CN=Test",
53 dns: ["DNS1", "DNS2"],
54 ip: ["192.168.1.1"],
55 applicationUri: "urn:HOSTNAME:ServerDescription",
56 purpose: CertificatePurpose.ForApplication,
57 });
58 console.log(cert);
59}
60demonstratePrivateKeyAndSelfSignedCertificateCreation();
61
62
63```
64
65Please refer to the examples directory for more specific use cases and comprehensive samples.
66
67
68## Support
69
70For any inquiries or issues related to NodeOPCUA Crypto, you can contact us at contact@sterfive.com. Please note that priority support is available to NodeOPCUA Support Subscription members.
71
72### Getting professional support
73
74NodeOPCUA PKI is developed and maintained by sterfive.com.
75
76To get professional support, consider subscribing to the node-opcua membership community:
77
78[![Professional Support](https://img.shields.io/static/v1?style=for-the-badge&label=Professional&message=Support&labelColor=blue&color=green&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDQ5MS41MiA0OTEuNTIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDQ5MS41MiA0OTEuNTI7IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBkPSJNNDg3Ljk4OSwzODkuNzU1bC05My4xMDktOTIuOTc2Yy00LjgxMy00LjgwNi0xMi42NDItNC42NzQtMTcuMjczLDAuMzA3Yy03LjE0OCw3LjY4OS0xNC42NCwxNS41NTQ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nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPC9zdmc+)](https://support.sterfive.com)
79
80or contact [sterfive](https://www.sterfive.com) for dedicated consulting and more advanced support.
81
82## Contributing
83
84We appreciate contributions from the community. To contribute:
85
86* Fork the repository.
87* Create a new branch.
88* Commit your changes.
89* Submit a pull request.
90* Sign the CLA (Contributor Licence Agreement) form
91
92For more detailed instructions, refer to the CONTRIBUTING.md file.
93
94## License
95
96NodeOPCUA Crypto is MIT licensed. See the LICENSE file for full license details.
97
98Copyright © 2023 Sterfive.com.
99
100## Disclaimer
101
102NodeOPCUA Crypto is provided as-is, and while we strive to ensure its quality and security, Sterfive.com cannot be held liable for any damage caused directly or indirectly by the usage of this module.
103
104Please report any issues or vulnerabilities you find via the issue tracker.
105
106Thank you for considering NodeOPCUA Crypto for your OPCUA cryptography needs. We look forward to seeing what you build with i
107
108
109
110## Supporting the development effort - Sponsors & Backers
111
112If you like `node-opcua-pki` and if you are relying on it in one of your projects, please consider becoming a backer and [sponsoring us](https://github.com/sponsors/node-opcua), this will help us to maintain a high-quality stack and constant evolution of this module.
113
114If your company would like to participate and influence the development of future versions of `node-opcua` please contact [sterfive](mailto:contact@sterfive.com).