node-opcua-server-configuration 2.163.1 → 2.164.2
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/dist/clientTools/certificate_types.d.ts +17 -0
- package/dist/clientTools/certificate_types.js +20 -0
- package/dist/clientTools/certificate_types.js.map +1 -0
- package/dist/clientTools/get_certificate_key_type.d.ts +6 -0
- package/dist/clientTools/get_certificate_key_type.js +55 -0
- package/dist/clientTools/get_certificate_key_type.js.map +1 -0
- package/dist/clientTools/index.d.ts +2 -1
- package/dist/clientTools/index.js +2 -17
- package/dist/clientTools/index.js.map +1 -1
- package/dist/clientTools/push_certificate_management_client.d.ts +10 -10
- package/dist/clientTools/push_certificate_management_client.js +85 -89
- package/dist/clientTools/push_certificate_management_client.js.map +1 -1
- package/dist/index.d.ts +9 -7
- package/dist/index.js +9 -23
- package/dist/index.js.map +1 -1
- package/dist/push_certificate_manager.d.ts +4 -4
- package/dist/push_certificate_manager.js +1 -2
- package/dist/server/certificate_validation.d.ts +15 -0
- package/dist/server/certificate_validation.js +76 -0
- package/dist/server/certificate_validation.js.map +1 -0
- package/dist/server/file_transaction_manager.d.ts +30 -0
- package/dist/server/file_transaction_manager.js +223 -0
- package/dist/server/file_transaction_manager.js.map +1 -0
- package/dist/server/install_certificate_file_watcher.d.ts +1 -1
- package/dist/server/install_certificate_file_watcher.js +8 -14
- package/dist/server/install_certificate_file_watcher.js.map +1 -1
- package/dist/server/install_push_certitifate_management.d.ts +6 -6
- package/dist/server/install_push_certitifate_management.js +61 -65
- package/dist/server/install_push_certitifate_management.js.map +1 -1
- package/dist/server/promote_trust_list.d.ts +1 -1
- package/dist/server/promote_trust_list.js +323 -82
- package/dist/server/promote_trust_list.js.map +1 -1
- package/dist/server/push_certificate_manager/apply_changes.d.ts +3 -0
- package/dist/server/push_certificate_manager/apply_changes.js +59 -0
- package/dist/server/push_certificate_manager/apply_changes.js.map +1 -0
- package/dist/server/push_certificate_manager/create_signing_request.d.ts +5 -0
- package/dist/server/push_certificate_manager/create_signing_request.js +108 -0
- package/dist/server/push_certificate_manager/create_signing_request.js.map +1 -0
- package/dist/server/push_certificate_manager/get_rejected_list.d.ts +3 -0
- package/dist/server/push_certificate_manager/get_rejected_list.js +46 -0
- package/dist/server/push_certificate_manager/get_rejected_list.js.map +1 -0
- package/dist/server/push_certificate_manager/internal_context.d.ts +35 -0
- package/dist/server/push_certificate_manager/internal_context.js +45 -0
- package/dist/server/push_certificate_manager/internal_context.js.map +1 -0
- package/dist/server/push_certificate_manager/subject_to_string.d.ts +3 -0
- package/dist/server/push_certificate_manager/subject_to_string.js +27 -0
- package/dist/server/push_certificate_manager/subject_to_string.js.map +1 -0
- package/dist/server/push_certificate_manager/update_certificate.d.ts +5 -0
- package/dist/server/push_certificate_manager/update_certificate.js +132 -0
- package/dist/server/push_certificate_manager/update_certificate.js.map +1 -0
- package/dist/server/push_certificate_manager/util.d.ts +29 -0
- package/dist/server/push_certificate_manager/util.js +117 -0
- package/dist/server/push_certificate_manager/util.js.map +1 -0
- package/dist/server/push_certificate_manager_helpers.d.ts +5 -2
- package/dist/server/push_certificate_manager_helpers.js +109 -112
- package/dist/server/push_certificate_manager_helpers.js.map +1 -1
- package/dist/server/push_certificate_manager_server_impl.d.ts +16 -29
- package/dist/server/push_certificate_manager_server_impl.js +49 -437
- package/dist/server/push_certificate_manager_server_impl.js.map +1 -1
- package/dist/server/roles_and_permissions.d.ts +1 -1
- package/dist/server/roles_and_permissions.js +24 -27
- package/dist/server/roles_and_permissions.js.map +1 -1
- package/dist/server/tools.d.ts +1 -1
- package/dist/server/tools.js +7 -13
- package/dist/server/tools.js.map +1 -1
- package/dist/server/trust_list_server.d.ts +2 -2
- package/dist/server/trust_list_server.js +40 -29
- package/dist/server/trust_list_server.js.map +1 -1
- package/dist/standard_certificate_types.js +6 -9
- package/dist/standard_certificate_types.js.map +1 -1
- package/dist/trust_list.d.ts +2 -2
- package/dist/trust_list.js +1 -2
- package/dist/trust_list_impl.js +1 -2
- package/dist/trust_list_impl.js.map +1 -1
- package/package.json +29 -30
- package/source/clientTools/certificate_types.ts +21 -0
- package/source/clientTools/get_certificate_key_type.ts +73 -0
- package/source/clientTools/index.ts +2 -1
- package/source/clientTools/push_certificate_management_client.ts +49 -44
- package/source/index.ts +9 -7
- package/source/push_certificate_manager.ts +15 -17
- package/source/server/certificate_validation.ts +103 -0
- package/source/server/file_transaction_manager.ts +253 -0
- package/source/server/install_certificate_file_watcher.ts +15 -11
- package/source/server/install_push_certitifate_management.ts +52 -51
- package/source/server/promote_trust_list.ts +362 -73
- package/source/server/push_certificate_manager/apply_changes.ts +63 -0
- package/source/server/push_certificate_manager/create_signing_request.ts +137 -0
- package/source/server/push_certificate_manager/get_rejected_list.ts +63 -0
- package/source/server/push_certificate_manager/internal_context.ts +63 -0
- package/source/server/push_certificate_manager/subject_to_string.ts +25 -0
- package/source/server/push_certificate_manager/update_certificate.ts +201 -0
- package/source/server/push_certificate_manager/util.ts +145 -0
- package/source/server/push_certificate_manager_helpers.ts +61 -51
- package/source/server/push_certificate_manager_server_impl.ts +94 -553
- package/source/server/roles_and_permissions.ts +7 -8
- package/source/server/tools.ts +2 -5
- package/source/server/trust_list_server.ts +24 -9
- package/source/standard_certificate_types.ts +2 -3
- package/source/trust_list.ts +26 -33
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { PermissionType, RolePermissionTypeOptions, WellKnownRoles } from "node-opcua-address-space";
|
|
2
|
-
import {
|
|
1
|
+
import { PermissionType, type RolePermissionTypeOptions, WellKnownRoles } from "node-opcua-address-space";
|
|
2
|
+
import { allPermissions, makePermissionFlag } from "node-opcua-data-model";
|
|
3
3
|
|
|
4
4
|
export const rolePermissionRestricted: RolePermissionTypeOptions[] = [
|
|
5
|
-
|
|
6
5
|
{
|
|
7
6
|
roleId: WellKnownRoles.Anonymous,
|
|
8
|
-
permissions: PermissionType.Browse
|
|
7
|
+
permissions: PermissionType.Browse
|
|
9
8
|
},
|
|
10
9
|
{
|
|
11
10
|
roleId: WellKnownRoles.AuthenticatedUser,
|
|
12
|
-
permissions: PermissionType.Browse
|
|
11
|
+
permissions: PermissionType.Browse
|
|
13
12
|
},
|
|
14
13
|
{
|
|
15
14
|
roleId: WellKnownRoles.ConfigureAdmin,
|
|
@@ -18,14 +17,14 @@ export const rolePermissionRestricted: RolePermissionTypeOptions[] = [
|
|
|
18
17
|
{
|
|
19
18
|
roleId: WellKnownRoles.SecurityAdmin,
|
|
20
19
|
permissions: allPermissions
|
|
21
|
-
}
|
|
20
|
+
}
|
|
22
21
|
];
|
|
23
22
|
export const rolePermissionAdminOnly: RolePermissionTypeOptions[] = [
|
|
24
23
|
{
|
|
25
24
|
roleId: WellKnownRoles.SecurityAdmin,
|
|
26
25
|
permissions: allPermissions
|
|
27
|
-
}
|
|
28
|
-
|
|
26
|
+
}
|
|
27
|
+
/* {
|
|
29
28
|
roleId: WellKnownRoles.Anonymous,
|
|
30
29
|
permissions: PermissionType.Browse
|
|
31
30
|
},
|
package/source/server/tools.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ISessionContext, WellKnownRoles } from "node-opcua-address-space";
|
|
1
|
+
import { type ISessionContext, WellKnownRoles } from "node-opcua-address-space";
|
|
2
2
|
import { MessageSecurityMode } from "node-opcua-secure-channel";
|
|
3
3
|
|
|
4
4
|
export function hasExpectedUserAccess(context: ISessionContext) {
|
|
5
|
-
if (!context ||
|
|
6
|
-
!context.session ||
|
|
7
|
-
!context.session.userIdentityToken) {
|
|
5
|
+
if (!context || !context.session || !context.session.userIdentityToken) {
|
|
8
6
|
return false;
|
|
9
7
|
}
|
|
10
8
|
return context.currentUserHasRole(WellKnownRoles.SecurityAdmin);
|
|
@@ -13,4 +11,3 @@ export function hasExpectedUserAccess(context: ISessionContext) {
|
|
|
13
11
|
export function hasEncryptedChannel(context: ISessionContext) {
|
|
14
12
|
return !!(context.session?.channel?.securityMode === MessageSecurityMode.SignAndEncrypt);
|
|
15
13
|
}
|
|
16
|
-
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
import { OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
5
|
-
import { TrustListDataType } from "node-opcua-types";
|
|
6
|
-
import { AbstractFs } from "node-opcua-file-transfer";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
7
3
|
import { BinaryStream } from "node-opcua-binary-stream";
|
|
4
|
+
import type { OPCUACertificateManager } from "node-opcua-certificate-manager";
|
|
8
5
|
import { readCertificate, readCertificateRevocationList } from "node-opcua-crypto";
|
|
9
6
|
import { make_errorLog } from "node-opcua-debug";
|
|
7
|
+
import type { AbstractFs } from "node-opcua-file-transfer";
|
|
8
|
+
import { TrustListDataType } from "node-opcua-types";
|
|
10
9
|
|
|
11
10
|
const errorLog = make_errorLog("TrustListServer");
|
|
12
11
|
|
|
@@ -20,6 +19,7 @@ async function readAll(folder: string): Promise<Buffer[]> {
|
|
|
20
19
|
const buf = await readCertificate(file);
|
|
21
20
|
results.push(buf);
|
|
22
21
|
} else if (ext === ".crl") {
|
|
22
|
+
// Strict validation: only accept valid CRL files
|
|
23
23
|
const buf = await readCertificateRevocationList(file);
|
|
24
24
|
results.push(buf);
|
|
25
25
|
} else {
|
|
@@ -53,13 +53,28 @@ export async function buildTrustList(
|
|
|
53
53
|
trustList.trustedCertificates = await readAll(certificateManager.trustedFolder);
|
|
54
54
|
}
|
|
55
55
|
if ((trustListFlag & TrustListMasks.TrustedCrls) === TrustListMasks.TrustedCrls) {
|
|
56
|
-
|
|
56
|
+
const crlFolder = certificateManager.crlFolder;
|
|
57
|
+
if (fs.existsSync(crlFolder)) {
|
|
58
|
+
trustList.trustedCrls = await readAll(crlFolder);
|
|
59
|
+
} else {
|
|
60
|
+
trustList.trustedCrls = [];
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
if ((trustListFlag & TrustListMasks.IssuerCertificates) === TrustListMasks.IssuerCertificates) {
|
|
59
|
-
|
|
64
|
+
const issuersCertFolder = certificateManager.issuersCertFolder;
|
|
65
|
+
if (fs.existsSync(issuersCertFolder)) {
|
|
66
|
+
trustList.issuerCertificates = await readAll(issuersCertFolder);
|
|
67
|
+
} else {
|
|
68
|
+
trustList.issuerCertificates = [];
|
|
69
|
+
}
|
|
60
70
|
}
|
|
61
71
|
if ((trustListFlag & TrustListMasks.IssuerCrls) === TrustListMasks.IssuerCrls) {
|
|
62
|
-
|
|
72
|
+
const issuersCrlFolder = certificateManager.issuersCrlFolder;
|
|
73
|
+
if (fs.existsSync(issuersCrlFolder)) {
|
|
74
|
+
trustList.issuerCrls = await readAll(issuersCrlFolder);
|
|
75
|
+
} else {
|
|
76
|
+
trustList.issuerCrls = [];
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
return trustList;
|
|
65
80
|
}
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { resolveNodeId } from "node-opcua-nodeid";
|
|
5
5
|
|
|
6
|
-
export const CertificateType =
|
|
6
|
+
export const CertificateType = {
|
|
7
7
|
Application: resolveNodeId("ApplicationCertificateType"),
|
|
8
8
|
Https: resolveNodeId("HttpsCertificateType"),
|
|
9
9
|
RsaMinApplication: resolveNodeId("RsaMinApplicationCertificateType"),
|
|
10
|
-
RsaSha256Application: resolveNodeId("RsaSha256ApplicationCertificateType")
|
|
10
|
+
RsaSha256Application: resolveNodeId("RsaSha256ApplicationCertificateType")
|
|
11
11
|
};
|
|
12
|
-
|
package/source/trust_list.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { StatusCode } from "node-opcua-status-code";
|
|
1
|
+
import type { StatusCode } from "node-opcua-status-code";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @module node-opcua-server-configuration
|
|
5
5
|
*/
|
|
6
6
|
export interface ITrustList {
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* The CloseAndUpdate Method closes the file and applies the changes to the Trust List. It can
|
|
10
9
|
* only be called if the file was opened for writing. If the Close Method is called any cached data
|
|
11
10
|
* is discarded and the Trust List is not changed.
|
|
12
|
-
*
|
|
11
|
+
*
|
|
13
12
|
* The Server shall verify that every Certificate in the new Trust List is valid according to the
|
|
14
13
|
* mandatory rules defined in Part 4. If an invalid Certificate is found the Server shall return an
|
|
15
14
|
* error and shall not update the Trust List. If only part of the Trust List is being updated the
|
|
16
15
|
* Server creates a temporary Trust List that includes the existing Trust List plus any updates
|
|
17
16
|
* and validates the temporary Trust List.
|
|
18
|
-
*
|
|
17
|
+
*
|
|
19
18
|
* If the file cannot be processed this Method still closes the file and discards the data before
|
|
20
19
|
* returning an error. This Method is required if the Server supports updates to the Trust List.
|
|
21
20
|
* The structure uploaded includes a mask (see 7.5.8) which specifies which fields are updated.
|
|
22
21
|
* If a bit is not set then the associated field is not changed.
|
|
23
|
-
*
|
|
22
|
+
*
|
|
24
23
|
* @param fileHandle UInt32 - The handle of the previously opened file
|
|
25
24
|
* @return applyChangesRequired - A flag indicating whether the ApplyChanges Method (see 7.7.5) shall be called
|
|
26
25
|
* before the new Trust List will be used by the Server.
|
|
@@ -31,46 +30,43 @@ export interface ITrustList {
|
|
|
31
30
|
* error.
|
|
32
31
|
*/
|
|
33
32
|
closeAndUpdate(
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// fileHandle: UInt32,
|
|
34
|
+
applyChangesRequired: boolean
|
|
36
35
|
): Promise<boolean>;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
|
-
* The AddCertificate Method allows a Client to add a single Certificate to the Trust List.
|
|
40
|
-
*
|
|
38
|
+
* The AddCertificate Method allows a Client to add a single Certificate to the Trust List.
|
|
39
|
+
*
|
|
41
40
|
* The Server shall verify that the Certificate is valid according to the rules defined in Part 4.
|
|
42
|
-
*
|
|
41
|
+
*
|
|
43
42
|
* If an invalid Certificate is found the Server shall return an error and shall not update the Trust List.
|
|
44
|
-
*
|
|
43
|
+
*
|
|
45
44
|
* If the Certificate is issued by a CA then the Client shall provide the entire chain in the
|
|
46
|
-
* certificate argument (see Part 6).
|
|
47
|
-
*
|
|
48
|
-
* After validating the Certificate, the Server shall add the CA Certificates to the Issuers list in the Trust List.
|
|
49
|
-
*
|
|
45
|
+
* certificate argument (see Part 6).
|
|
46
|
+
*
|
|
47
|
+
* After validating the Certificate, the Server shall add the CA Certificates to the Issuers list in the Trust List.
|
|
48
|
+
*
|
|
50
49
|
* The leaf Certificate is added to the list specified by the isTrustedCertificate argument.
|
|
51
|
-
*
|
|
50
|
+
*
|
|
52
51
|
* This method cannot be called if the file object is open
|
|
53
52
|
* @param certificate - The DER encoded Certificate to add as a ByteStrng
|
|
54
|
-
* @param
|
|
53
|
+
* @param isTrustedCerticopy ficate - If TRUE the Certificate is added to the Trusted Certificates List. If FALSE the Certificate is added to the Issuer Certificates List.
|
|
55
54
|
*
|
|
56
|
-
* **Result Code**
|
|
55
|
+
* **Result Code**
|
|
57
56
|
* - BadUserAccessDenied: The current user does not have the rights required.
|
|
58
57
|
* - BadCertificateInvalid: The certificate to add is invalid.
|
|
59
58
|
* - BadInvalidState: The object is opened.
|
|
60
|
-
*
|
|
59
|
+
*
|
|
61
60
|
*/
|
|
62
|
-
addCertificate(
|
|
63
|
-
certificate: Buffer,
|
|
64
|
-
isTrustedCertificate: boolean
|
|
65
|
-
): Promise<StatusCode>;
|
|
61
|
+
addCertificate(certificate: Buffer, isTrustedCertificate: boolean): Promise<StatusCode>;
|
|
66
62
|
|
|
67
63
|
/**
|
|
68
|
-
* The RemoveCertificate Method allows a Client to remove a single Certificate from the Trust List.
|
|
69
|
-
*
|
|
64
|
+
* The RemoveCertificate Method allows a Client to remove a single Certificate from the Trust List.
|
|
65
|
+
*
|
|
70
66
|
* It returns BadInvalidArgument if the thumbprint does not match a Certificate in the Trust List.
|
|
71
|
-
*
|
|
67
|
+
*
|
|
72
68
|
* If the Certificate is a CA Certificate with associated CRLs then all CRLs are removed as well.
|
|
73
|
-
*
|
|
69
|
+
*
|
|
74
70
|
* This method cannot be called if the file object is open.
|
|
75
71
|
*
|
|
76
72
|
* @param thumbprint - The SHA1 hash of the Certificate to remove
|
|
@@ -81,11 +77,8 @@ export interface ITrustList {
|
|
|
81
77
|
* -BadUserAccessDenied: The current user does not have the rights required.
|
|
82
78
|
* -BadInvalidArgument: The certificate to remove was not found.
|
|
83
79
|
* -BadInvalidState: The object is opened.
|
|
84
|
-
*
|
|
85
|
-
*
|
|
80
|
+
*
|
|
81
|
+
*
|
|
86
82
|
*/
|
|
87
|
-
removeCertificate(
|
|
88
|
-
thumbprint: string,
|
|
89
|
-
isTrustedCertificate: boolean
|
|
90
|
-
): Promise<StatusCode>;
|
|
83
|
+
removeCertificate(thumbprint: string, isTrustedCertificate: boolean): Promise<StatusCode>;
|
|
91
84
|
}
|