node-opcua-pki 3.0.2 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ignore +6 -6
- package/.prettierrc +5 -5
- package/LICENSE +22 -22
- package/bin/crypto_create_CA.js +0 -0
- package/bin/crypto_create_CA_config.example.js +18 -18
- package/bin/install_prerequisite.js +9 -9
- package/dist/crypto_create_CA.d.ts +2 -2
- package/dist/crypto_create_CA.js +897 -897
- package/dist/index.d.ts +6 -6
- package/dist/index.js +44 -44
- package/dist/misc/applicationurn.d.ts +1 -1
- package/dist/misc/applicationurn.js +46 -46
- package/dist/misc/hostname.d.ts +8 -8
- package/dist/misc/hostname.js +102 -102
- package/dist/misc/install_prerequisite.d.ts +9 -9
- package/dist/misc/install_prerequisite.js +363 -360
- package/dist/misc/install_prerequisite.js.map +1 -1
- package/dist/misc/subject.d.ts +26 -26
- package/dist/misc/subject.js +121 -121
- package/dist/pki/certificate_authority.d.ts +61 -61
- package/dist/pki/certificate_authority.js +481 -481
- package/dist/pki/certificate_manager.d.ts +144 -144
- package/dist/pki/certificate_manager.js +883 -883
- package/dist/pki/certificate_manager.js.map +1 -1
- package/dist/pki/common.d.ts +5 -5
- package/dist/pki/common.js +2 -2
- package/dist/pki/templates/ca_config_template.cnf.d.ts +2 -2
- package/dist/pki/templates/ca_config_template.cnf.js +129 -129
- package/dist/pki/templates/simple_config_template.cnf.d.ts +2 -2
- package/dist/pki/templates/simple_config_template.cnf.js +75 -75
- package/dist/pki/toolbox.d.ts +160 -160
- package/dist/pki/toolbox.js +699 -699
- package/dist/pki/toolbox_pfx.js +18 -18
- package/lib/crypto_create_CA.ts +1135 -1135
- package/lib/index.ts +28 -28
- package/lib/misc/applicationurn.ts +45 -45
- package/lib/misc/hostname.ts +89 -89
- package/lib/misc/install_prerequisite.ts +454 -454
- package/lib/misc/subject.ts +141 -141
- package/lib/pki/certificate_manager.ts +1 -1
- package/lib/pki/common.ts +5 -5
- package/lib/pki/templates/ca_config_template.cnf.ts +129 -129
- package/lib/pki/templates/simple_config_template.cnf.ts +75 -75
- package/lib/pki/toolbox_pfx.ts +19 -19
- package/package.json +89 -89
- package/readme.md +214 -214
- package/tsconfig.json +20 -20
- package/dist/misc/fs.d.ts +0 -24
- package/dist/misc/fs.js +0 -21
- package/dist/misc/fs.js.map +0 -1
- package/dist/misc/get_default_filesystem.d.ts +0 -2
- package/dist/misc/get_default_filesystem.js +0 -9
- package/dist/misc/get_default_filesystem.js.map +0 -1
package/lib/misc/subject.ts
CHANGED
|
@@ -1,141 +1,141 @@
|
|
|
1
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
-
// node-opcua-pki
|
|
3
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
-
// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org
|
|
5
|
-
// Copyright (c) 2022 - Sterfive.com
|
|
6
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
7
|
-
//
|
|
8
|
-
// This project is licensed under the terms of the MIT license.
|
|
9
|
-
//
|
|
10
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
11
|
-
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
12
|
-
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
-
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
14
|
-
//
|
|
15
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
16
|
-
// Software.
|
|
17
|
-
//
|
|
18
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
19
|
-
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
20
|
-
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
-
// ---------------------------------------------------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
export interface SubjectOptions {
|
|
25
|
-
commonName?: string;
|
|
26
|
-
organization?: string;
|
|
27
|
-
organizationalUnit?: string;
|
|
28
|
-
locality?: string;
|
|
29
|
-
state?: string;
|
|
30
|
-
country?: string;
|
|
31
|
-
domainComponent?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const _keys = {
|
|
35
|
-
C: "country",
|
|
36
|
-
CN: "commonName",
|
|
37
|
-
DC: "domainComponent",
|
|
38
|
-
L: "locality",
|
|
39
|
-
O: "organization",
|
|
40
|
-
OU: "organizationalUnit",
|
|
41
|
-
ST: "state",
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const enquoteIfNecessary = (str: string) => {
|
|
45
|
-
str = str.replace(/"/g, "”");
|
|
46
|
-
return str.match(/\/|=/) ? `"${str}"` : str;
|
|
47
|
-
};
|
|
48
|
-
const unquote = (str: string) => str.replace(/"/gm, "");
|
|
49
|
-
const unquote2 = (str?: string | undefined) => {
|
|
50
|
-
if (!str) return str;
|
|
51
|
-
const m = str.match(/^"(.*)"$/);
|
|
52
|
-
return m ? m[1] : str;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* subjectName The subject name to use for the Certificate.
|
|
56
|
-
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
57
|
-
*/
|
|
58
|
-
export class Subject implements SubjectOptions {
|
|
59
|
-
public readonly commonName?: string;
|
|
60
|
-
public readonly organization?: string;
|
|
61
|
-
public readonly organizationalUnit?: string;
|
|
62
|
-
public readonly locality?: string;
|
|
63
|
-
public readonly state?: string;
|
|
64
|
-
public readonly country?: string;
|
|
65
|
-
public readonly domainComponent?: string;
|
|
66
|
-
|
|
67
|
-
constructor(options: SubjectOptions | string) {
|
|
68
|
-
if (typeof options === "string") {
|
|
69
|
-
options = Subject.parse(options);
|
|
70
|
-
}
|
|
71
|
-
this.commonName = unquote2(options.commonName);
|
|
72
|
-
this.organization = unquote2(options.organization);
|
|
73
|
-
this.organizationalUnit = unquote2(options.organizationalUnit);
|
|
74
|
-
this.locality = unquote2(options.locality);
|
|
75
|
-
this.state = unquote2(options.state);
|
|
76
|
-
this.country = unquote2(options.country);
|
|
77
|
-
this.domainComponent = unquote2(options.domainComponent);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
public static parse(str: string): SubjectOptions {
|
|
81
|
-
const elements = str.split(/\/(?=[^/]*?=)/);
|
|
82
|
-
const options: Record<string, unknown> = {};
|
|
83
|
-
|
|
84
|
-
elements.forEach((element: string) => {
|
|
85
|
-
if (element.length === 0) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const s: string[] = element.split("=");
|
|
89
|
-
|
|
90
|
-
if (s.length !== 2) {
|
|
91
|
-
throw new Error("invalid format for " + element);
|
|
92
|
-
}
|
|
93
|
-
const longName = (_keys as Record<string, string>)[s[0]];
|
|
94
|
-
if (!longName) {
|
|
95
|
-
throw new Error("Invalid field found in subject name " + s[0]);
|
|
96
|
-
}
|
|
97
|
-
const value = s[1];
|
|
98
|
-
options[longName] = unquote(Buffer.from(value, "ascii").toString("utf8"));
|
|
99
|
-
});
|
|
100
|
-
return options as SubjectOptions;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public toStringForOPCUA(): string {
|
|
104
|
-
// https://reference.opcfoundation.org/v104/GDS/docs/7.6.4/
|
|
105
|
-
// The format of the subject name is a sequence of name value pairs separated by a ‘/’.
|
|
106
|
-
// The name shall be one of ‘CN’, ‘O’, ‘OU’, ‘DC’, ‘L’, ‘S’ or ‘C’ and
|
|
107
|
-
// shall be followed by a ‘=’ and then followed by the value.
|
|
108
|
-
// The value may be any printable character except for ‘”’.
|
|
109
|
-
// If the value contains a ‘/’ or a ‘=’ then it shall be enclosed in double quotes (‘”’).
|
|
110
|
-
|
|
111
|
-
const tmp: string[] = [];
|
|
112
|
-
if (this.country) {
|
|
113
|
-
tmp.push("C=" + enquoteIfNecessary(this.country));
|
|
114
|
-
}
|
|
115
|
-
if (this.state) {
|
|
116
|
-
tmp.push("ST=" + enquoteIfNecessary(this.state));
|
|
117
|
-
}
|
|
118
|
-
if (this.locality) {
|
|
119
|
-
tmp.push("L=" + enquoteIfNecessary(this.locality));
|
|
120
|
-
}
|
|
121
|
-
if (this.organization) {
|
|
122
|
-
tmp.push("O=" + enquoteIfNecessary(this.organization));
|
|
123
|
-
}
|
|
124
|
-
if (this.organizationalUnit) {
|
|
125
|
-
tmp.push("OU=" + enquoteIfNecessary(this.organizationalUnit));
|
|
126
|
-
}
|
|
127
|
-
if (this.commonName) {
|
|
128
|
-
tmp.push("CN=" + enquoteIfNecessary(this.commonName));
|
|
129
|
-
}
|
|
130
|
-
if (this.domainComponent) {
|
|
131
|
-
tmp.push("DC=" + enquoteIfNecessary(this.domainComponent));
|
|
132
|
-
}
|
|
133
|
-
return tmp.join("/");
|
|
134
|
-
}
|
|
135
|
-
public toString(): string {
|
|
136
|
-
// standard for SSL is to have a / in front of each Field
|
|
137
|
-
// see https://www.digicert.com/kb/ssl-support/openssl-quick-reference-guide.htm
|
|
138
|
-
const t = this.toStringForOPCUA();
|
|
139
|
-
return t ? "/" + t : t;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
1
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
2
|
+
// node-opcua-pki
|
|
3
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
4
|
+
// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org
|
|
5
|
+
// Copyright (c) 2022 - Sterfive.com
|
|
6
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
7
|
+
//
|
|
8
|
+
// This project is licensed under the terms of the MIT license.
|
|
9
|
+
//
|
|
10
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
11
|
+
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
12
|
+
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
//
|
|
15
|
+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
16
|
+
// Software.
|
|
17
|
+
//
|
|
18
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
19
|
+
// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
20
|
+
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
21
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
// ---------------------------------------------------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
export interface SubjectOptions {
|
|
25
|
+
commonName?: string;
|
|
26
|
+
organization?: string;
|
|
27
|
+
organizationalUnit?: string;
|
|
28
|
+
locality?: string;
|
|
29
|
+
state?: string;
|
|
30
|
+
country?: string;
|
|
31
|
+
domainComponent?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const _keys = {
|
|
35
|
+
C: "country",
|
|
36
|
+
CN: "commonName",
|
|
37
|
+
DC: "domainComponent",
|
|
38
|
+
L: "locality",
|
|
39
|
+
O: "organization",
|
|
40
|
+
OU: "organizationalUnit",
|
|
41
|
+
ST: "state",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const enquoteIfNecessary = (str: string) => {
|
|
45
|
+
str = str.replace(/"/g, "”");
|
|
46
|
+
return str.match(/\/|=/) ? `"${str}"` : str;
|
|
47
|
+
};
|
|
48
|
+
const unquote = (str: string) => str.replace(/"/gm, "");
|
|
49
|
+
const unquote2 = (str?: string | undefined) => {
|
|
50
|
+
if (!str) return str;
|
|
51
|
+
const m = str.match(/^"(.*)"$/);
|
|
52
|
+
return m ? m[1] : str;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* subjectName The subject name to use for the Certificate.
|
|
56
|
+
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
57
|
+
*/
|
|
58
|
+
export class Subject implements SubjectOptions {
|
|
59
|
+
public readonly commonName?: string;
|
|
60
|
+
public readonly organization?: string;
|
|
61
|
+
public readonly organizationalUnit?: string;
|
|
62
|
+
public readonly locality?: string;
|
|
63
|
+
public readonly state?: string;
|
|
64
|
+
public readonly country?: string;
|
|
65
|
+
public readonly domainComponent?: string;
|
|
66
|
+
|
|
67
|
+
constructor(options: SubjectOptions | string) {
|
|
68
|
+
if (typeof options === "string") {
|
|
69
|
+
options = Subject.parse(options);
|
|
70
|
+
}
|
|
71
|
+
this.commonName = unquote2(options.commonName);
|
|
72
|
+
this.organization = unquote2(options.organization);
|
|
73
|
+
this.organizationalUnit = unquote2(options.organizationalUnit);
|
|
74
|
+
this.locality = unquote2(options.locality);
|
|
75
|
+
this.state = unquote2(options.state);
|
|
76
|
+
this.country = unquote2(options.country);
|
|
77
|
+
this.domainComponent = unquote2(options.domainComponent);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public static parse(str: string): SubjectOptions {
|
|
81
|
+
const elements = str.split(/\/(?=[^/]*?=)/);
|
|
82
|
+
const options: Record<string, unknown> = {};
|
|
83
|
+
|
|
84
|
+
elements.forEach((element: string) => {
|
|
85
|
+
if (element.length === 0) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const s: string[] = element.split("=");
|
|
89
|
+
|
|
90
|
+
if (s.length !== 2) {
|
|
91
|
+
throw new Error("invalid format for " + element);
|
|
92
|
+
}
|
|
93
|
+
const longName = (_keys as Record<string, string>)[s[0]];
|
|
94
|
+
if (!longName) {
|
|
95
|
+
throw new Error("Invalid field found in subject name " + s[0]);
|
|
96
|
+
}
|
|
97
|
+
const value = s[1];
|
|
98
|
+
options[longName] = unquote(Buffer.from(value, "ascii").toString("utf8"));
|
|
99
|
+
});
|
|
100
|
+
return options as SubjectOptions;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public toStringForOPCUA(): string {
|
|
104
|
+
// https://reference.opcfoundation.org/v104/GDS/docs/7.6.4/
|
|
105
|
+
// The format of the subject name is a sequence of name value pairs separated by a ‘/’.
|
|
106
|
+
// The name shall be one of ‘CN’, ‘O’, ‘OU’, ‘DC’, ‘L’, ‘S’ or ‘C’ and
|
|
107
|
+
// shall be followed by a ‘=’ and then followed by the value.
|
|
108
|
+
// The value may be any printable character except for ‘”’.
|
|
109
|
+
// If the value contains a ‘/’ or a ‘=’ then it shall be enclosed in double quotes (‘”’).
|
|
110
|
+
|
|
111
|
+
const tmp: string[] = [];
|
|
112
|
+
if (this.country) {
|
|
113
|
+
tmp.push("C=" + enquoteIfNecessary(this.country));
|
|
114
|
+
}
|
|
115
|
+
if (this.state) {
|
|
116
|
+
tmp.push("ST=" + enquoteIfNecessary(this.state));
|
|
117
|
+
}
|
|
118
|
+
if (this.locality) {
|
|
119
|
+
tmp.push("L=" + enquoteIfNecessary(this.locality));
|
|
120
|
+
}
|
|
121
|
+
if (this.organization) {
|
|
122
|
+
tmp.push("O=" + enquoteIfNecessary(this.organization));
|
|
123
|
+
}
|
|
124
|
+
if (this.organizationalUnit) {
|
|
125
|
+
tmp.push("OU=" + enquoteIfNecessary(this.organizationalUnit));
|
|
126
|
+
}
|
|
127
|
+
if (this.commonName) {
|
|
128
|
+
tmp.push("CN=" + enquoteIfNecessary(this.commonName));
|
|
129
|
+
}
|
|
130
|
+
if (this.domainComponent) {
|
|
131
|
+
tmp.push("DC=" + enquoteIfNecessary(this.domainComponent));
|
|
132
|
+
}
|
|
133
|
+
return tmp.join("/");
|
|
134
|
+
}
|
|
135
|
+
public toString(): string {
|
|
136
|
+
// standard for SSL is to have a / in front of each Field
|
|
137
|
+
// see https://www.digicert.com/kb/ssl-support/openssl-quick-reference-guide.htm
|
|
138
|
+
const t = this.toStringForOPCUA();
|
|
139
|
+
return t ? "/" + t : t;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -397,7 +397,7 @@ export class CertificateManager {
|
|
|
397
397
|
if (!issuerCertificate) {
|
|
398
398
|
// if the certificate is not self-signed we ust have a issuer.
|
|
399
399
|
// but no Issuer is not found
|
|
400
|
-
return VerificationStatus.
|
|
400
|
+
return VerificationStatus.BadCertificateChainIncomplete;
|
|
401
401
|
}
|
|
402
402
|
const issuerStatus = await this._innerVerifyCertificateAsync(issuerCertificate, true, level + 1);
|
|
403
403
|
if (issuerStatus === VerificationStatus.BadCertificateRevocationUnknown) {
|
package/lib/pki/common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type KeySize = 1024 | 2048 | 3072 | 4096;
|
|
2
|
-
export type Thumbprint = string;
|
|
3
|
-
export type Filename = string;
|
|
4
|
-
export type CertificateStatus = "unknown" | "trusted" | "rejected";
|
|
5
|
-
export type ErrorCallback = (err?: Error | null) => void;
|
|
1
|
+
export type KeySize = 1024 | 2048 | 3072 | 4096;
|
|
2
|
+
export type Thumbprint = string;
|
|
3
|
+
export type Filename = string;
|
|
4
|
+
export type CertificateStatus = "unknown" | "trusted" | "rejected";
|
|
5
|
+
export type ErrorCallback = (err?: Error | null) => void;
|
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
const config =
|
|
2
|
-
"#.........DO NOT MODIFY BY HAND .........................\n" +
|
|
3
|
-
"[ ca ]\n" +
|
|
4
|
-
"default_ca = CA_default\n" +
|
|
5
|
-
"[ CA_default ]\n" +
|
|
6
|
-
"dir = %%ROOT_FOLDER%% # the main CA folder\n" +
|
|
7
|
-
"certs = $dir/certs # where to store certificates\n" +
|
|
8
|
-
"new_certs_dir = $dir/certs #\n" +
|
|
9
|
-
"database = $dir/index.txt # the certificate database\n" +
|
|
10
|
-
"serial = $dir/serial # the serial number counter\n" +
|
|
11
|
-
"certificate = $dir/public/cacert.pem # The root CA certificate\n" +
|
|
12
|
-
"private_key = $dir/private/cakey.pem # the CA private key\n" +
|
|
13
|
-
"x509_extensions = usr_cert #\n" +
|
|
14
|
-
"default_days = 3650 # default validity : 10 years\n" +
|
|
15
|
-
"\n" +
|
|
16
|
-
"# default_md = sha1\n" +
|
|
17
|
-
"\n" +
|
|
18
|
-
"default_md = sha256 # The default digest algorithm\n" +
|
|
19
|
-
"\n" +
|
|
20
|
-
"preserve = no\n" +
|
|
21
|
-
"policy = policy_match\n" +
|
|
22
|
-
"# randfile = $dir/random.rnd\n" +
|
|
23
|
-
"# default_startdate = YYMMDDHHMMSSZ\n" +
|
|
24
|
-
"# default_enddate = YYMMDDHHMMSSZ\n" +
|
|
25
|
-
"crl_dir = $dir/crl\n" +
|
|
26
|
-
"crl_extensions = crl_ext\n" +
|
|
27
|
-
"crl = $dir/revocation_list.crl # the Revocation list\n" +
|
|
28
|
-
"crlnumber = $dir/crlnumber # CRL number file\n" +
|
|
29
|
-
"default_crl_days = 30\n" +
|
|
30
|
-
"default_crl_hours = 24\n" +
|
|
31
|
-
"#msie_hack\n" +
|
|
32
|
-
"\n" +
|
|
33
|
-
"[ policy_match ]\n" +
|
|
34
|
-
"countryName = optional\n" +
|
|
35
|
-
"stateOrProvinceName = optional\n" +
|
|
36
|
-
"localityName = optional\n" +
|
|
37
|
-
"organizationName = optional\n" +
|
|
38
|
-
"organizationalUnitName = optional\n" +
|
|
39
|
-
"commonName = optional\n" +
|
|
40
|
-
"emailAddress = optional\n" +
|
|
41
|
-
"\n" +
|
|
42
|
-
"[ req ]\n" +
|
|
43
|
-
"default_bits = 4096 # Size of keys\n" +
|
|
44
|
-
"default_keyfile = key.pem # name of generated keys\n" +
|
|
45
|
-
"distinguished_name = req_distinguished_name\n" +
|
|
46
|
-
"attributes = req_attributes\n" +
|
|
47
|
-
"x509_extensions = v3_ca\n" +
|
|
48
|
-
"#input_password\n" +
|
|
49
|
-
"#output_password\n" +
|
|
50
|
-
"string_mask = nombstr # permitted characters\n" +
|
|
51
|
-
"req_extensions = v3_req\n" +
|
|
52
|
-
"\n" +
|
|
53
|
-
"[ req_distinguished_name ]\n" +
|
|
54
|
-
"\n" +
|
|
55
|
-
"#0 countryName = Country Name (2 letter code)\n" +
|
|
56
|
-
"# countryName_default = FR\n" +
|
|
57
|
-
"# countryName_min = 2\n" +
|
|
58
|
-
"# countryName_max = 2\n" +
|
|
59
|
-
"# stateOrProvinceName = State or Province Name (full name)\n" +
|
|
60
|
-
"# stateOrProvinceName_default = Ile de France\n" +
|
|
61
|
-
"# localityName = Locality Name (city, district)\n" +
|
|
62
|
-
"# localityName_default = Paris\n" +
|
|
63
|
-
"organizationName = Organization Name (company)\n" +
|
|
64
|
-
"organizationName_default = NodeOPCUA\n" +
|
|
65
|
-
"# organizationalUnitName = Organizational Unit Name (department, division)\n" +
|
|
66
|
-
"# organizationalUnitName_default = R&D\n" +
|
|
67
|
-
"commonName = Common Name (hostname, FQDN, IP, or your name)\n" +
|
|
68
|
-
"commonName_max = 256\n" +
|
|
69
|
-
"commonName_default = NodeOPCUA\n" +
|
|
70
|
-
"# emailAddress = Email Address\n" +
|
|
71
|
-
"# emailAddress_max = 40\n" +
|
|
72
|
-
"# emailAddress_default = node-opcua (at) node-opcua (dot) com\n" +
|
|
73
|
-
"\n" +
|
|
74
|
-
"[ req_attributes ]\n" +
|
|
75
|
-
"#challengePassword = A challenge password\n" +
|
|
76
|
-
"#challengePassword_min = 4\n" +
|
|
77
|
-
"#challengePassword_max = 20\n" +
|
|
78
|
-
"#unstructuredName = An optional company name\n" +
|
|
79
|
-
"[ usr_cert ]\n" +
|
|
80
|
-
"basicConstraints = critical, CA:FALSE\n" +
|
|
81
|
-
"subjectKeyIdentifier = hash\n" +
|
|
82
|
-
"authorityKeyIdentifier = keyid,issuer:always\n" +
|
|
83
|
-
"#authorityKeyIdentifier = keyid\n" +
|
|
84
|
-
"subjectAltName = $ENV::ALTNAME\n" +
|
|
85
|
-
"# issuerAltName = issuer:copy\n" +
|
|
86
|
-
"nsComment = ''OpenSSL Generated Certificate''\n" +
|
|
87
|
-
"#nsCertType = client, email, objsign for ''everything including object signing''\n" +
|
|
88
|
-
"#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem\n" +
|
|
89
|
-
"#nsBaseUrl =\n" +
|
|
90
|
-
"#nsRenewalUrl =\n" +
|
|
91
|
-
"#nsCaPolicyUrl =\n" +
|
|
92
|
-
"#nsSslServerName =\n" +
|
|
93
|
-
"keyUsage = critical, digitalSignature, nonRepudiation," +
|
|
94
|
-
" keyEncipherment, dataEncipherment, keyAgreement, keyCertSign\n" +
|
|
95
|
-
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
96
|
-
"\n" +
|
|
97
|
-
"[ v3_req ]\n" +
|
|
98
|
-
"basicConstraints = critical, CA:FALSE\n" +
|
|
99
|
-
"keyUsage = nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyAgreement\n" +
|
|
100
|
-
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
101
|
-
"subjectAltName = $ENV::ALTNAME\n" +
|
|
102
|
-
"nsComment = \"CA Generated by Node-OPCUA Certificate utility using openssl\"\n" +
|
|
103
|
-
"[ v3_ca ]\n" +
|
|
104
|
-
"subjectKeyIdentifier = hash\n" +
|
|
105
|
-
"authorityKeyIdentifier = keyid:always,issuer:always\n" +
|
|
106
|
-
"# authorityKeyIdentifier = keyid\n" +
|
|
107
|
-
"basicConstraints = CA:TRUE\n" +
|
|
108
|
-
"keyUsage = critical, cRLSign, keyCertSign\n" +
|
|
109
|
-
"nsComment = \"CA Certificate generated by Node-OPCUA Certificate utility using openssl\"\n" +
|
|
110
|
-
"#nsCertType = sslCA, emailCA\n" +
|
|
111
|
-
"#subjectAltName = email:copy\n" +
|
|
112
|
-
"#issuerAltName = issuer:copy\n" +
|
|
113
|
-
"#obj = DER:02:03\n" +
|
|
114
|
-
"crlDistributionPoints = @crl_info\n" +
|
|
115
|
-
"[ crl_info ]\n" +
|
|
116
|
-
"URI.0 = http://localhost:8900/crl.pem\n" +
|
|
117
|
-
"[ v3_selfsigned]\n" +
|
|
118
|
-
"basicConstraints = critical, CA:FALSE\n" +
|
|
119
|
-
"keyUsage = nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyAgreement\n" +
|
|
120
|
-
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
121
|
-
"nsComment = \"Self-signed certificate, generated by NodeOPCUA\"\n" +
|
|
122
|
-
"subjectAltName = $ENV::ALTNAME\n" +
|
|
123
|
-
"\n" +
|
|
124
|
-
"[ crl_ext ]\n" +
|
|
125
|
-
"#issuerAltName = issuer:copy\n" +
|
|
126
|
-
"authorityKeyIdentifier = keyid:always,issuer:always\n" +
|
|
127
|
-
"#authorityInfoAccess = @issuer_info";
|
|
128
|
-
|
|
129
|
-
export default config;
|
|
1
|
+
const config =
|
|
2
|
+
"#.........DO NOT MODIFY BY HAND .........................\n" +
|
|
3
|
+
"[ ca ]\n" +
|
|
4
|
+
"default_ca = CA_default\n" +
|
|
5
|
+
"[ CA_default ]\n" +
|
|
6
|
+
"dir = %%ROOT_FOLDER%% # the main CA folder\n" +
|
|
7
|
+
"certs = $dir/certs # where to store certificates\n" +
|
|
8
|
+
"new_certs_dir = $dir/certs #\n" +
|
|
9
|
+
"database = $dir/index.txt # the certificate database\n" +
|
|
10
|
+
"serial = $dir/serial # the serial number counter\n" +
|
|
11
|
+
"certificate = $dir/public/cacert.pem # The root CA certificate\n" +
|
|
12
|
+
"private_key = $dir/private/cakey.pem # the CA private key\n" +
|
|
13
|
+
"x509_extensions = usr_cert #\n" +
|
|
14
|
+
"default_days = 3650 # default validity : 10 years\n" +
|
|
15
|
+
"\n" +
|
|
16
|
+
"# default_md = sha1\n" +
|
|
17
|
+
"\n" +
|
|
18
|
+
"default_md = sha256 # The default digest algorithm\n" +
|
|
19
|
+
"\n" +
|
|
20
|
+
"preserve = no\n" +
|
|
21
|
+
"policy = policy_match\n" +
|
|
22
|
+
"# randfile = $dir/random.rnd\n" +
|
|
23
|
+
"# default_startdate = YYMMDDHHMMSSZ\n" +
|
|
24
|
+
"# default_enddate = YYMMDDHHMMSSZ\n" +
|
|
25
|
+
"crl_dir = $dir/crl\n" +
|
|
26
|
+
"crl_extensions = crl_ext\n" +
|
|
27
|
+
"crl = $dir/revocation_list.crl # the Revocation list\n" +
|
|
28
|
+
"crlnumber = $dir/crlnumber # CRL number file\n" +
|
|
29
|
+
"default_crl_days = 30\n" +
|
|
30
|
+
"default_crl_hours = 24\n" +
|
|
31
|
+
"#msie_hack\n" +
|
|
32
|
+
"\n" +
|
|
33
|
+
"[ policy_match ]\n" +
|
|
34
|
+
"countryName = optional\n" +
|
|
35
|
+
"stateOrProvinceName = optional\n" +
|
|
36
|
+
"localityName = optional\n" +
|
|
37
|
+
"organizationName = optional\n" +
|
|
38
|
+
"organizationalUnitName = optional\n" +
|
|
39
|
+
"commonName = optional\n" +
|
|
40
|
+
"emailAddress = optional\n" +
|
|
41
|
+
"\n" +
|
|
42
|
+
"[ req ]\n" +
|
|
43
|
+
"default_bits = 4096 # Size of keys\n" +
|
|
44
|
+
"default_keyfile = key.pem # name of generated keys\n" +
|
|
45
|
+
"distinguished_name = req_distinguished_name\n" +
|
|
46
|
+
"attributes = req_attributes\n" +
|
|
47
|
+
"x509_extensions = v3_ca\n" +
|
|
48
|
+
"#input_password\n" +
|
|
49
|
+
"#output_password\n" +
|
|
50
|
+
"string_mask = nombstr # permitted characters\n" +
|
|
51
|
+
"req_extensions = v3_req\n" +
|
|
52
|
+
"\n" +
|
|
53
|
+
"[ req_distinguished_name ]\n" +
|
|
54
|
+
"\n" +
|
|
55
|
+
"#0 countryName = Country Name (2 letter code)\n" +
|
|
56
|
+
"# countryName_default = FR\n" +
|
|
57
|
+
"# countryName_min = 2\n" +
|
|
58
|
+
"# countryName_max = 2\n" +
|
|
59
|
+
"# stateOrProvinceName = State or Province Name (full name)\n" +
|
|
60
|
+
"# stateOrProvinceName_default = Ile de France\n" +
|
|
61
|
+
"# localityName = Locality Name (city, district)\n" +
|
|
62
|
+
"# localityName_default = Paris\n" +
|
|
63
|
+
"organizationName = Organization Name (company)\n" +
|
|
64
|
+
"organizationName_default = NodeOPCUA\n" +
|
|
65
|
+
"# organizationalUnitName = Organizational Unit Name (department, division)\n" +
|
|
66
|
+
"# organizationalUnitName_default = R&D\n" +
|
|
67
|
+
"commonName = Common Name (hostname, FQDN, IP, or your name)\n" +
|
|
68
|
+
"commonName_max = 256\n" +
|
|
69
|
+
"commonName_default = NodeOPCUA\n" +
|
|
70
|
+
"# emailAddress = Email Address\n" +
|
|
71
|
+
"# emailAddress_max = 40\n" +
|
|
72
|
+
"# emailAddress_default = node-opcua (at) node-opcua (dot) com\n" +
|
|
73
|
+
"\n" +
|
|
74
|
+
"[ req_attributes ]\n" +
|
|
75
|
+
"#challengePassword = A challenge password\n" +
|
|
76
|
+
"#challengePassword_min = 4\n" +
|
|
77
|
+
"#challengePassword_max = 20\n" +
|
|
78
|
+
"#unstructuredName = An optional company name\n" +
|
|
79
|
+
"[ usr_cert ]\n" +
|
|
80
|
+
"basicConstraints = critical, CA:FALSE\n" +
|
|
81
|
+
"subjectKeyIdentifier = hash\n" +
|
|
82
|
+
"authorityKeyIdentifier = keyid,issuer:always\n" +
|
|
83
|
+
"#authorityKeyIdentifier = keyid\n" +
|
|
84
|
+
"subjectAltName = $ENV::ALTNAME\n" +
|
|
85
|
+
"# issuerAltName = issuer:copy\n" +
|
|
86
|
+
"nsComment = ''OpenSSL Generated Certificate''\n" +
|
|
87
|
+
"#nsCertType = client, email, objsign for ''everything including object signing''\n" +
|
|
88
|
+
"#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem\n" +
|
|
89
|
+
"#nsBaseUrl =\n" +
|
|
90
|
+
"#nsRenewalUrl =\n" +
|
|
91
|
+
"#nsCaPolicyUrl =\n" +
|
|
92
|
+
"#nsSslServerName =\n" +
|
|
93
|
+
"keyUsage = critical, digitalSignature, nonRepudiation," +
|
|
94
|
+
" keyEncipherment, dataEncipherment, keyAgreement, keyCertSign\n" +
|
|
95
|
+
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
96
|
+
"\n" +
|
|
97
|
+
"[ v3_req ]\n" +
|
|
98
|
+
"basicConstraints = critical, CA:FALSE\n" +
|
|
99
|
+
"keyUsage = nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyAgreement\n" +
|
|
100
|
+
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
101
|
+
"subjectAltName = $ENV::ALTNAME\n" +
|
|
102
|
+
"nsComment = \"CA Generated by Node-OPCUA Certificate utility using openssl\"\n" +
|
|
103
|
+
"[ v3_ca ]\n" +
|
|
104
|
+
"subjectKeyIdentifier = hash\n" +
|
|
105
|
+
"authorityKeyIdentifier = keyid:always,issuer:always\n" +
|
|
106
|
+
"# authorityKeyIdentifier = keyid\n" +
|
|
107
|
+
"basicConstraints = CA:TRUE\n" +
|
|
108
|
+
"keyUsage = critical, cRLSign, keyCertSign\n" +
|
|
109
|
+
"nsComment = \"CA Certificate generated by Node-OPCUA Certificate utility using openssl\"\n" +
|
|
110
|
+
"#nsCertType = sslCA, emailCA\n" +
|
|
111
|
+
"#subjectAltName = email:copy\n" +
|
|
112
|
+
"#issuerAltName = issuer:copy\n" +
|
|
113
|
+
"#obj = DER:02:03\n" +
|
|
114
|
+
"crlDistributionPoints = @crl_info\n" +
|
|
115
|
+
"[ crl_info ]\n" +
|
|
116
|
+
"URI.0 = http://localhost:8900/crl.pem\n" +
|
|
117
|
+
"[ v3_selfsigned]\n" +
|
|
118
|
+
"basicConstraints = critical, CA:FALSE\n" +
|
|
119
|
+
"keyUsage = nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyAgreement\n" +
|
|
120
|
+
"extendedKeyUsage = critical,serverAuth ,clientAuth\n" +
|
|
121
|
+
"nsComment = \"Self-signed certificate, generated by NodeOPCUA\"\n" +
|
|
122
|
+
"subjectAltName = $ENV::ALTNAME\n" +
|
|
123
|
+
"\n" +
|
|
124
|
+
"[ crl_ext ]\n" +
|
|
125
|
+
"#issuerAltName = issuer:copy\n" +
|
|
126
|
+
"authorityKeyIdentifier = keyid:always,issuer:always\n" +
|
|
127
|
+
"#authorityInfoAccess = @issuer_info";
|
|
128
|
+
|
|
129
|
+
export default config;
|