Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-opcua-pki

node-opcua126.8kMIT5.3.0TypeScript support: included

PKI management for node-opcua

PKI, node-opcua

readme

node-opcua-pki

NPM download NPM version Build Status Coverage Status install size FOSSA Status

Installation

install globally
$ npm install -g node-opcua-pki
$ crypto_create_CA --help
use with npx
npx node-opcua-pki --help
npx node-opcua-pki certificate --help

Note: see https://reference.opcfoundation.org/GDS/docs/F.1/

commands

command Help
demo create default certificate for node-opcua demos
createCA create a Certificate Authority
createPKI create a Public Key Infrastructure
certificate create a new certificate
csr create a new certificate signing request(CSR)
sign sign a CSR and generate a certificate
revoke revoke an existing certificate
dump display a certificate
toder convert a certificate to a DER format
fingerprint print the certificate fingerprint

Options: --help display help

create a PKI

node-opcua-pki createPKI

Options:

option description type default
-r, --root the location of the Certificate folder [string] [default: "{CWD}/certificates"]
--PKIFolder the location of the Public Key Infrastructure [string] [default: "{root}/PKI"]
-k, --keySize, --keyLength the private key size in bits (1024,2048,3072,4096) [number] [default: 2048]
-s, --silent minimize output [boolean] [default: false]

The result

└─ 📂certificates
    └─📂PKI
       ├─📂issuers
       │ ├─📂certs                 contains known Certificate Authorities' certificates
       │ └─📂crl                   contains Certificate Revocation List associates with the CA Certificates
       ├─📂own
       │ ├─📂certs                 where to store generated public certificates generated for the private key.
       │ └─📂private
       │    └─🔐private_key.pem  the private key in PEM format
       ├─📂rejected                  contains certificates that have been rejected.
       └─📂trusted
         ├─📂certs                 contains the X.509 v3 Certificates that are trusted.
         └─📂crl                   contains the X.509 v3 CRLs for any Certificates in the ./certs directory.

create a Certificate Signing Request (CSR)

Options: | option | description | type | default | |---------------------|-------------------------------------------------|--------|-----------------------------------------------| |-a, --applicationUri |the application URI |[string]|[default: "urn:{hostname}:Node-OPCUA-Server"] | |-o, --output | the name of the generated signing_request |[string]|[default: "my_certificate_signing_request.csr"]| |--dns | the list of valid domain name (comma separated) |[string]|[default: "{hostname}"] | |--ip | the list of valid IPs (comma separated) |[string]|[default: ""] | |--subject | the certificate subject ( for instance /C=FR/ST=Centre/L=Orleans/O=SomeOrganization/CN=Hello )|[string]| [default: "/CN=Certificate"]| |-r, --root | the location of the Certificate folder |[string]|[default: "{CWD}/certificates"] | |--PKIFolder | the location of the Public Key Infrastructure |[string]|[default: "{root}/PKI"] |

Create a certificate authority

| | | default value | | -------------------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------- | | --subject | the CA certificate subject | "/C=FR/ST=IDF/L=Paris/O=Local NODE-OPCUA Certificate Authority/CN=NodeOPCUA-CA" | | --root, -r | the location of the Certificate folder | "{CWD}/certificates" | | --CAFolder, -c | the location of the Certificate Authority folder | "{root}/CA"] | | --keySize, -k, --keyLength | the private key size in bits (1024, 2048 ,3072, 4096)| |

The result

└─ 📂certificates
    └─📂PKI
       ├─📂CA           Certificate Authority
       ├─📂rejected     The Certificate store contains certificates that have been rejected.
       │ ├─📂certs      Contains the X.509 v3 Certificates which have been rejected.
       ├─📂trusted      The Certificate store contains trusted Certificates.
       │ ├─📂certs      Contains the X.509 v3 Certificates that are trusted.
       │ └─📂crl        Contains the X.509 v3 CRLs for any Certificates in the ./certs directory.
       ├─📂issuers      The Certificate store contains the CA Certificates needed for validation.
       │ ├─📂certs      Contains the X.509 v3 Certificates that are needed for validation.
       │ ├─📂crl        Contains the X.509 v3 CRLs for any Certificates in the ./certs directory.

sign a signing request (requires a CA)

option description type default
-i, --csr the csr [string] [required] [default: "my_certificate_signing_request.csr"]
-o, --output the name of the generated certificate [string] [required] [default: "my_certificate.pem"]
-v, --validity the certificate validity in days [number] [default: 365]
-r, --root the location of the Certificate folder [string] [default: "{CWD}/certificates"]
-c, --CAFolder the location of the Certificate Authority folder [string] [default: "{root}/CA"]

demo command

this command creates a bunch of certificates with various characteristics for demo and testing purposes.

crypto_create_CA  demo [--dev] [--silent] [--clean]

Options:

| | | | | ------------ | -------------------------------------------------------------- | ------------------ | | --help | display help | | | --dev | create all sort of fancy certificates for dev testing purposes | | | --clean | Purge existing directory [use with care!] | | | --silent, -s | minimize output | | | --root, -r | the location of the Certificate folder | {CWD}/certificates |

Example:

$crypto_create_CA  demo --dev
certificate command
$crypto_create_CA certificate --help

Options:

| | | | | -------------------- | ---------------------------------------------------------------------------------------------- | -------------------------------- | | --help | display help | | | --applicationUri, -a | the application URI | urn:{hostname}:Node-OPCUA-Server | | --output, -o | the name of the generated certificate | my_certificate.pem | | --selfSigned, -s | if true, the certificate will be self-signed | false | | --validity, -v | the certificate validity in days | | | --silent, -s | minimize output | | | --root, -r | the location of the Certificate folder | {CWD}/certificates | | --CAFolder, -c | the location of the Certificate Authority folder | {root}/CA | | --PKIFolder, -p | the location of the Public Key Infrastructure | {root}/PKI | | --privateKey, -p | optional:the private key to use to generate certificate | | | --subject | the certificate subject ( for instance /C=FR/ST=Centre/L=Orleans/O=SomeOrganization/CN=Hello ) | |

examples
  • create a self-signed certificate
npx node-opcua-pki certificate --dns=machine1.com,machine2.com --ip="192.1.2.3;192.3.4.5" -a 'urn:{hostname}:My-OPCUA-Server' --selfSigned -o  my_self_signed_certificate.pem

References

prerequisite:

This module requires OpenSSL or LibreSSL to be installed.

On Windows, a version of OpenSSL is automatically downloaded and installed at run time, if not present. You will need an internet connection open.

You need to install it on Linux, (or in your docker image), or on macOS

  • on ubuntu/Debian:
apt install openssl

or alpine:

apk add openssl

Support

Sterfive provides this module free of charge, “as is,” with the hope that it will be useful to you. However, any support requests, bug fixes, or enhancements are handled exclusively through our paid services. We believe strongly that independent open-source companies should be fairly compensated for their contributions to the community.

We highly recommend subscribing to our support program to ensure your requests are addressed and resolved. Please note that we only consider requests from members of our support program or sponsors.

Getting professional support

NodeOPCUA PKI is developed and maintained by sterfive.com.

To get professional support, consider subscribing to the node-opcua membership community:

Professional Support

or contact sterfive for dedicated consulting and more advanced support.

:heart: Supporting the development effort - Sponsors & Backers

If 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, this will help us to maintain a high-quality stack and constant evolution of this module.

If your company would like to participate and influence the development of future versions of node-opcua please contact sterfive.

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

5.3.0

  • update packages f0a315c
  • fix certificate generation when uniformResourceIdentifier is not present 8e287ed
  • remove cli-table dependency b37726d

5.2.0

9 March 2025

  • generate signing request without openssl in CA 399a051
  • fix openssl issue that could cause command to fail when rootDir is a relative path b0f6425
  • chore: minor cleanup 34d173e

5.1.0

29 January 2025

  • chore: release v5.1.0 157c08e
  • fix installation of openssl on windows 4d21f2b
  • remove tests certificates from packages 6613e6e

5.0.0

29 January 2025

  • BREAKING CHANGE: remove callback support to favor async/await 85a6262
  • chore: formatting 4e0af65
  • update copyright year 6eadac5

4.18.0

16 December 2024

  • chore: release v4.18.0 65ef098
  • replace deprecate string.substr with string.substring 735ebe3
  • buildIdealCertificateName now replace / or \ with _ to avoid building invalid filename from certificate CN 20aee24

4.17.0

14 December 2024

  • add publish github action d71bd1f

4.16.0

13 October 2024

4.15.0

5 October 2024

4.14.0

24 September 2024

4.13.1

6 September 2024

4.13.0

6 September 2024

4.12.0

6 September 2024

4.11.1

16 July 2024

4.11.0

16 July 2024

4.10.0

25 February 2024

4.9.0

21 January 2024

  • update node-opcua-crypto to v4.7.0 51a594b
  • fix: upgrade rimraf from 4.0.0 to 4.4.1 b57703a
  • update copyright year a45d4b1

4.8.1

19 November 2023

4.8.0

18 November 2023

4.7.0

6 September 2023

4.6.0

5 September 2023

4.5.0

3 September 2023

  • update packages 92fc2ea
  • fix ci.yml not to use npm@10 with old version of node 1b54005
  • remove appveyor support 9f05e91

4.4.0

17 August 2023

4.3.0

14 August 2023

  • update packages, remove nyc b65f7ab
  • update packages 41efb37
  • add option to accept outdated or pending certificates during verification a7d1f9a

4.2.1

10 June 2023

4.2.0

2 June 2023

  • rename createPrivateKey => generatePrivateKeyFile 0359bac
  • Release 4.2.0 2b8ed0e

4.1.1

1 June 2023

4.1.0

1 June 2023

4.0.2

31 May 2023

4.0.1

31 May 2023

4.0.0

27 May 2023

  • update packages cd83450
  • add example for self signed cert creation with multiple DNS and IP fields 1ab713a
  • Release 4.0.0 2e34ef9

4.0.0-beta.9

23 May 2023

4.0.0-beta.8

21 May 2023

4.0.0-beta.7

21 May 2023

  • Release 4.0.0-beta.7 b4a7784
  • fix export of CertificateAuthority 4ace5d3

4.0.0-beta.6

21 May 2023

  • Release 4.0.0-beta.6 9366e75
  • add CertificateAuthority.d.ts in root folder 89b0adc

4.0.0-beta.5

21 May 2023

  • Release 4.0.0-beta.5 1e604bd
  • fix package.json and npm ignore file 6dbdbf3

4.0.0-beta.4

21 May 2023

  • fix package.json and npm ignore file 0ca9642
  • Release 4.0.0-beta.4 9e9ea8c

4.0.0-beta.3

21 May 2023

4.0.0-beta.2

21 May 2023

4.0.0-beta.1

21 May 2023

  • refactor and use node-opcua-crypto@3 e0e7337
  • update copyright notice and lint fixes 1cb62b4
  • Release 4.0.0-beta.1 bee236a

3.1.2

6 May 2023

  • adjust _innerVerifyCertificateAsync with issuer certificate detection f685132
  • Release 3.1.2 dbeccc7

3.1.1

6 May 2023

3.1.0

6 May 2023

  • update packages and introduce BadCertificateChainIncomplete when CA certificate missing 0a3b29e
  • Release 3.1.0 24356f5

3.0.2

8 January 2023

  • udpdate package fix json5 vulnerability 19f07bc
  • Release 3.0.2 9ec6d69
  • fix the problem of createPKI never end 9493e52

3.0.1

15 December 2022

3.0.0

14 December 2022

2.19.1

5 December 2022

2.19.0

5 December 2022

2.18.4

24 November 2022

  • fix unexpected quoted random.rnd filename bc59266
  • Release 2.18.4 140fbf4

2.18.3

5 November 2022

  • call ensure_openssl_installed only when necessary 65b0fd4
  • Release 2.18.3 ed91b5f

2.18.2

3 November 2022

  • Release 2.18.2 b776509
  • fix bin/pki entry in package.json to make it work on windows 795cbe2

2.18.1

3 November 2022

2.18.0

22 October 2022

2.17.0

25 June 2022

2.16.0

25 June 2022

  • update package and temporarily remove use of update-notifier b2424ab
  • Release 2.16.0 204572e

2.15.4

28 March 2022

2.15.3

28 March 2022

2.15.2

28 March 2022

  • use alternate wget-improved-2 maintained by node-opcua d662912
  • Release 2.15.2 381f395

2.15.1

28 March 2022

  • chore: address minimist vulnerability again db33cf7
  • Release 2.15.1 c4f9ef7

2.15.0

27 March 2022

2.14.2

26 March 2022

  • chore: add eslint support 59beb17
  • chore: update minimist to fix vulnerability issue 578dc83
  • chore: update Readme ad42c10

2.14.1

4 March 2022

  • fixed slashes in Subject CN #25
  • Release 2.14.1 ef0fbee

2.14.0

27 February 2022

2.13.0

5 December 2021

2.12.1

27 September 2021

  • fix: use windowsHide in exec #23
  • Release 2.12.1 37c2fc4

2.12.0

5 September 2021

2.11.2

19 July 2021

2.11.1

30 May 2021

2.11.0

30 May 2021

2.10.0

30 May 2021

2.9.8

10 April 2021

  • ensure openssl version is know before signing cert req 2229f15
  • ensure openssl version is know before signing cert req ddb2058
  • Release 2.9.8 9202be0

2.9.7

5 April 2021

  • Release 2.9.7 7434962
  • fix demo client certificate applicationUri e033f94

2.9.6

5 April 2021

  • make sure rootfolder exists before locking e3e5dd1
  • Release 2.9.6 e30d991

2.9.5

5 April 2021

2.9.2

3 April 2021

2.9.1

29 March 2021

2.9.0

28 March 2021

  • update package remove postinstall step 029c3d1
  • add semaphore to prevent concurrent access 56f4ab7
  • add GitLab Actions and fix coverage fc8916c

2.8.0

20 January 2021

  • update version 1574901
  • remove keyCertSign flag in keyUsage for standard certficate 163c5bc
  • minor refactoring 50e45e5

2.7.0

6 January 2021

  • migrate yargs commands to most recent api 4394cf8
  • no revocation for self-signed certificate ccb2197
  • use CertificateManager#dispose c447335

2.6.1

31 December 2020

2.6.0

31 December 2020

2.5.0

30 December 2020

  • apply subjectAltName from CSR to signed certificate a523d28
  • Release 2.5.0 9d5a58f

2.4.0

20 December 2020

2.3.0

12 December 2020

2.2.2

11 October 2020

2.2.1

11 October 2020

2.2.0

10 October 2020

2.1.8

9 October 2020

2.1.7

1 October 2020

  • update package and downgrade update-notifier 541cd87
  • Release 2.1.7 17d7520

2.1.6

30 September 2020

2.1.5

19 September 2020

2.1.4

19 September 2020

2.1.3

21 August 2020

  • add ability to pass subject description 9528f6e
  • Release 2.1.3 53aab53

2.1.2

19 August 2020

2.1.1

18 August 2020

  • make sure revocation lists are immediadely handled 392ab39
  • downgrade mocha d46de45
  • update packages 33073ed

2.1.0

10 August 2020

  • adjustments and minor fixes dc4ded8
  • chore: update package-lock 3a99fa6
  • Bump lodash from 4.17.15 to 4.17.19 6816bcb

2.0.4

30 June 2020

  • download openssl with proxy setting #11 c3535b5
  • Bump jsrsasign from 8.0.15 to 8.0.20 43517a8
  • Release 2.0.4 4c71e70

2.0.3

31 May 2020

2.0.2

18 May 2020

2.0.1

15 May 2020

2.0.0

14 May 2020

  • add issuers/certs management 0e23e4d
  • revamped Certificate manager 1739181
  • add Certifiicate Revocation List support 9c59e82

1.5.5

13 January 2020

1.5.4

11 November 2019

1.5.3

20 July 2019

1.5.2

10 May 2019

1.5.1

7 May 2019

1.5.0

6 May 2019

  • fix self-signed certificate extensions (#425) f604beb
  • Release 1.5.0 c446de9

1.4.1

4 May 2019

1.4.0

29 April 2019

1.3.1

13 April 2019

1.3.0

13 April 2019

  • refactor certificate verification 2c7b4c3
  • fix help to display --dns and --ip 52d0a0e
  • Release 1.3.0 1de9010

1.2.3

8 April 2019

1.2.2

8 April 2019

  • fix createSelfSignedCertificate parameters 9bf33ba
  • Release 1.2.2 4a5bf7b

1.2.1

7 April 2019

1.2.0

6 April 2019

1.1.1

2 April 2019

1.1.0

2 April 2019

v1.1.0

2 April 2019

  • OpenSSL random file does not exist #8
  • promisify certificate_manager 97b220b
  • Newer versions of OpenSSL does not create random files if them don't exist anymore. 209090d
  • Release 1.1.0 ffb0701

1.0.3

9 February 2019

v1.0.2

12 January 2019

  • do not recreate existing certificates if exists in demo mode 62af08a
  • Release 1.0.2 9bb6332

v1.0.1

25 November 2018

v1.0.0

28 October 2018

v1.0.0-beta.2

19 September 2018

  • fix typescript port for openssl install on windows e7d9be9
  • Release 1.0.0-beta.2 d85aec4

v1.0.0-beta.1

19 September 2018

v1.0.0-beta.0

19 September 2018

0.0.31

27 May 2018

0.0.30

7 April 2018

0.0.29

23 January 2018

  • LibreSSL Support #5
  • remove requirish 6e77844
  • Generating a temp config with injected environment variables. Support for LibreSSL. 5e82ae6
  • Less code duplication. bfc1eba

0.0.28

10 December 2017

  • add ability to create CA and PKI with 3072 & 4096 bits keys 875ae1b
  • Release 0.0.28 5c076b5

0.0.27

9 December 2017

0.0.26

2 December 2017

0.0.25

2 December 2017

  • TypeError: Path must be a string. Received undefined #3
  • Release 0.0.25 8dec88c
  • get_openssl_folder_win32 now returns local ssl path if LOCALAPPDATA environment variable is set AND the Programs directory does not exist. 658c83a

0.0.24

2 November 2017

0.0.23

1 November 2017

0.0.22

1 November 2017

0.0.21

25 October 2017

0.0.20

25 October 2017

0.0.19

25 October 2017

  • install openssl %LOCALAPPDATA%\Programs by default on windows bba9c46
  • fix installation of prerequisite openssl.exe 2184f1e
  • Release 0.0.19 b7aa331

0.0.18

24 October 2017

  • fix installation of prerequisite openssl.exe 0484820
  • update package.json 7ed63aa
  • add appveyor file 23a8528

0.0.17

18 June 2017

0.0.15

18 June 2017

  • add appveyor file c3242c9
  • use async version to check that openssl file exists 4c7136b
  • Release 0.0.15 8f36cf7

0.0.14

13 June 2017

0.0.13

7 May 2017

0.0.12

8 April 2017

0.0.11

14 December 2016

  • improve self-signed certificate creation from command line, add fingerprint and toder commands 4dc1f2b
  • improve support of subjectAlternativeName d511e56
  • allow 2 digits year in date when installed openssl version is 0.98 894a109

0.0.10

21 November 2016

0.0.9

12 November 2016

0.0.8

28 October 2016

  • fix openssl installation folder on windows dfb3b5b
  • Release 0.0.8 0310b66

0.0.7

28 October 2016

0.0.6

28 October 2016

  • fix openssl issue on windows caused by antivirus fa0a943
  • Release 0.0.6 94bf379

0.0.4

3 July 2016

0.0.3

23 May 2016

  • Release 0.0.3 59d3565
  • exclude unwanted files from npm module d604e36

0.0.2

23 May 2016