node-opcua-server-configuration 2.163.1 → 2.165.0
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 +15 -0
- package/dist/clientTools/certificate_types.js +19 -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 +6 -5
- 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 +59 -81
- 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 +348 -82
- package/dist/server/promote_trust_list.js.map +1 -1
- package/dist/server/push_certificate_manager/apply_changes.d.ts +4 -0
- package/dist/server/push_certificate_manager/apply_changes.js +65 -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 +134 -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 +110 -113
- package/dist/server/push_certificate_manager_helpers.js.map +1 -1
- package/dist/server/push_certificate_manager_server_impl.d.ts +37 -30
- package/dist/server/push_certificate_manager_server_impl.js +58 -438
- 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 +30 -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 +17 -18
- 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 -68
- package/source/server/promote_trust_list.ts +392 -73
- package/source/server/push_certificate_manager/apply_changes.ts +73 -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 +203 -0
- package/source/server/push_certificate_manager/util.ts +145 -0
- package/source/server/push_certificate_manager_helpers.ts +62 -52
- package/source/server/push_certificate_manager_server_impl.ts +133 -552
- 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,44 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-server-configuration
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import path from "node:path";
|
|
6
7
|
import {
|
|
7
|
-
AddressSpace,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
type AddressSpace,
|
|
9
|
+
type ISessionContext,
|
|
10
|
+
instantiateCertificateExpirationAlarm,
|
|
11
|
+
type UACertificateExpirationAlarmEx,
|
|
12
|
+
type UACertificateGroup,
|
|
13
|
+
type UAMethod,
|
|
14
|
+
type UAServerConfiguration,
|
|
15
|
+
type UATrustList
|
|
15
16
|
} from "node-opcua-address-space";
|
|
16
|
-
import { UAObject, UAVariable
|
|
17
|
-
|
|
18
|
-
import {
|
|
17
|
+
import { EventNotifierFlags, type UAObject, type UAVariable } from "node-opcua-address-space-base";
|
|
18
|
+
import type { ByteString, UAString } from "node-opcua-basic-types";
|
|
19
|
+
import { ObjectIds, ObjectTypeIds } from "node-opcua-constants";
|
|
20
|
+
import { type Certificate, readCertificate } from "node-opcua-crypto";
|
|
21
|
+
import { AccessRestrictionsFlag, BrowseDirection, coerceQualifiedName, NodeClass } from "node-opcua-data-model";
|
|
22
|
+
import { make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
19
23
|
import { NodeId, resolveNodeId } from "node-opcua-nodeid";
|
|
24
|
+
import type { CertificateManager } from "node-opcua-pki";
|
|
20
25
|
import { StatusCodes } from "node-opcua-status-code";
|
|
21
|
-
import { CallMethodResultOptions } from "node-opcua-types";
|
|
22
|
-
import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
|
|
23
|
-
import { AccessRestrictionsFlag, BrowseDirection, coerceQualifiedName, NodeClass } from "node-opcua-data-model";
|
|
24
|
-
import { ByteString, UAString } from "node-opcua-basic-types";
|
|
25
|
-
import { ObjectIds, ObjectTypeIds } from "node-opcua-constants";
|
|
26
|
-
import { CertificateManager } from "node-opcua-pki";
|
|
27
|
-
import { Certificate, readCertificate } from "node-opcua-crypto";
|
|
28
|
-
|
|
29
|
-
import { CreateSigningRequestResult, PushCertificateManager } from "../push_certificate_manager";
|
|
26
|
+
import type { CallMethodResultOptions } from "node-opcua-types";
|
|
27
|
+
import { DataType, type Variant, VariantArrayType } from "node-opcua-variant";
|
|
30
28
|
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
29
|
+
import type { CreateSigningRequestResult, PushCertificateManager } from "../push_certificate_manager.js";
|
|
30
|
+
import { installCertificateFileWatcher } from "./install_certificate_file_watcher.js";
|
|
31
|
+
import { installAccessRestrictionOnTrustList, promoteTrustList } from "./promote_trust_list.js";
|
|
32
|
+
import {
|
|
33
|
+
PushCertificateManagerServerImpl,
|
|
34
|
+
type PushCertificateManagerServerOptions
|
|
35
|
+
} from "./push_certificate_manager_server_impl.js";
|
|
36
|
+
import { rolePermissionAdminOnly, rolePermissionRestricted } from "./roles_and_permissions.js";
|
|
37
|
+
import { hasEncryptedChannel, hasExpectedUserAccess } from "./tools.js";
|
|
36
38
|
|
|
37
39
|
const debugLog = make_debugLog("ServerConfiguration");
|
|
38
|
-
const doDebug = checkDebugFlag("ServerConfiguration");
|
|
39
|
-
doDebug;
|
|
40
40
|
const warningLog = make_warningLog("ServerConfiguration");
|
|
41
|
-
const errorLog =
|
|
41
|
+
const errorLog = make_errorLog("ServerConfiguration");
|
|
42
42
|
|
|
43
43
|
function expected(variant: Variant | undefined, dataType: DataType, variantArrayType: VariantArrayType): boolean {
|
|
44
44
|
if (!variant) {
|
|
@@ -55,7 +55,7 @@ function expected(variant: Variant | undefined, dataType: DataType, variantArray
|
|
|
55
55
|
|
|
56
56
|
function getPushCertificateManager(method: UAMethod): PushCertificateManager | null {
|
|
57
57
|
const serverConfiguration = method.addressSpace.rootFolder.objects.server.getChildByName("ServerConfiguration");
|
|
58
|
-
const serverConfigurationPriv = serverConfiguration as
|
|
58
|
+
const serverConfigurationPriv = serverConfiguration as unknown as UAServerConfigurationPriv;
|
|
59
59
|
if (serverConfigurationPriv.$pushCertificateManager) {
|
|
60
60
|
return serverConfigurationPriv.$pushCertificateManager;
|
|
61
61
|
}
|
|
@@ -159,7 +159,7 @@ async function _updateCertificate(
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
if (privateKeyFormat && privateKeyFormat !== "" && privateKeyFormat.toLowerCase() !== "pem") {
|
|
162
|
-
errorLog(
|
|
162
|
+
errorLog(`_updateCertificate: Invalid PEM format requested ${privateKeyFormat}`);
|
|
163
163
|
return { statusCode: StatusCodes.BadInvalidArgument };
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -186,7 +186,7 @@ async function _updateCertificate(
|
|
|
186
186
|
outputArguments: [
|
|
187
187
|
{
|
|
188
188
|
dataType: DataType.Boolean,
|
|
189
|
-
value: result.applyChangesRequired
|
|
189
|
+
value: result.applyChangesRequired ?? false
|
|
190
190
|
}
|
|
191
191
|
],
|
|
192
192
|
statusCode: result.statusCode
|
|
@@ -196,7 +196,7 @@ async function _updateCertificate(
|
|
|
196
196
|
|
|
197
197
|
async function _getRejectedList(
|
|
198
198
|
this: UAMethod,
|
|
199
|
-
|
|
199
|
+
_inputArguments: Variant[],
|
|
200
200
|
context: ISessionContext
|
|
201
201
|
): Promise<CallMethodResultOptions> {
|
|
202
202
|
if (!hasEncryptedChannel(context)) {
|
|
@@ -231,7 +231,7 @@ async function _getRejectedList(
|
|
|
231
231
|
|
|
232
232
|
async function _applyChanges(
|
|
233
233
|
this: UAMethod,
|
|
234
|
-
|
|
234
|
+
_inputArguments: Variant[],
|
|
235
235
|
context: ISessionContext
|
|
236
236
|
): Promise<CallMethodResultOptions> {
|
|
237
237
|
// This Method requires an encrypted channel and that the Client provide credentials with
|
|
@@ -247,7 +247,7 @@ async function _applyChanges(
|
|
|
247
247
|
if (!pushCertificateManager) {
|
|
248
248
|
return { statusCode: StatusCodes.BadNotImplemented };
|
|
249
249
|
}
|
|
250
|
-
const statusCode = await pushCertificateManager.applyChanges();
|
|
250
|
+
const statusCode = await pushCertificateManager.applyChanges(context);
|
|
251
251
|
return { statusCode };
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -298,11 +298,13 @@ function bindCertificateGroup(certificateGroup: UACertificateGroup, certificateM
|
|
|
298
298
|
}
|
|
299
299
|
const trustList = certificateGroup.getComponentByName("TrustList");
|
|
300
300
|
if (trustList) {
|
|
301
|
-
(trustList as
|
|
301
|
+
(trustList as unknown as { $$certificateManager: CertificateManager }).$$certificateManager = certificateManager;
|
|
302
302
|
}
|
|
303
303
|
const certificateExpired = certificateGroup.getComponentByName("CertificateExpired");
|
|
304
304
|
if (certificateExpired) {
|
|
305
|
-
(
|
|
305
|
+
(
|
|
306
|
+
certificateExpired as unknown as UACertificateExpirationAlarmEx & { $$certificateManager: CertificateManager }
|
|
307
|
+
).$$certificateManager = certificateManager;
|
|
306
308
|
// install alarm handling
|
|
307
309
|
const timerId = setInterval(updateCertificateAlarm, 60 * 1000);
|
|
308
310
|
addressSpace.registerShutdownTask(() => clearInterval(timerId));
|
|
@@ -313,7 +315,7 @@ function bindCertificateGroup(certificateGroup: UACertificateGroup, certificateM
|
|
|
313
315
|
function bindCertificateManager(addressSpace: AddressSpace, options: PushCertificateManagerServerOptions) {
|
|
314
316
|
const serverConfiguration = addressSpace.rootFolder.objects.server.getChildByName(
|
|
315
317
|
"ServerConfiguration"
|
|
316
|
-
)
|
|
318
|
+
) as UAServerConfiguration;
|
|
317
319
|
|
|
318
320
|
const defaultApplicationGroup = serverConfiguration.certificateGroups.getComponentByName(
|
|
319
321
|
"DefaultApplicationGroup"
|
|
@@ -339,12 +341,11 @@ function setNotifierOfChain(childObject: UAObject | null) {
|
|
|
339
341
|
}
|
|
340
342
|
const notifierOf = childObject.findReferencesEx("HasNotifier", BrowseDirection.Inverse);
|
|
341
343
|
if (notifierOf.length === 0) {
|
|
342
|
-
|
|
344
|
+
childObject.addReference({
|
|
343
345
|
referenceType: "HasNotifier",
|
|
344
346
|
nodeId: parentObject.nodeId,
|
|
345
347
|
isForward: false
|
|
346
348
|
});
|
|
347
|
-
notifierOfNode;
|
|
348
349
|
}
|
|
349
350
|
parentObject.setEventNotifier(parentObject.eventNotifier | EventNotifierFlags.SubscribeToEvents);
|
|
350
351
|
if (parentObject.nodeId.namespace === 0 && parentObject.nodeId.value === ObjectIds.Server) {
|
|
@@ -388,11 +389,11 @@ export async function installPushCertificateManagement(
|
|
|
388
389
|
|
|
389
390
|
const serverConfiguration = addressSpace.rootFolder.objects.server.getChildByName(
|
|
390
391
|
"ServerConfiguration"
|
|
391
|
-
)
|
|
392
|
+
) as UAServerConfiguration;
|
|
392
393
|
|
|
393
394
|
const serverConfigurationPriv = serverConfiguration as UAServerConfigurationPriv;
|
|
394
395
|
if (serverConfigurationPriv.$pushCertificateManager) {
|
|
395
|
-
|
|
396
|
+
debugLog("PushCertificateManagement has already been installed");
|
|
396
397
|
return;
|
|
397
398
|
}
|
|
398
399
|
|
|
@@ -418,12 +419,15 @@ export async function installPushCertificateManagement(
|
|
|
418
419
|
updateCertificate?.setRolePermissions(rolePermissionAdminOnly);
|
|
419
420
|
updateCertificate?.setAccessRestrictions(accessRestrictionFlag);
|
|
420
421
|
|
|
421
|
-
const certificateGroups = serverConfiguration.getComponentByName("CertificateGroups")
|
|
422
|
+
const certificateGroups = serverConfiguration.getComponentByName("CertificateGroups");
|
|
423
|
+
if (!certificateGroups) {
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
422
426
|
certificateGroups.setRolePermissions(rolePermissionRestricted);
|
|
423
427
|
certificateGroups.setAccessRestrictions(AccessRestrictionsFlag.None);
|
|
424
428
|
|
|
425
429
|
function installAccessRestrictionOnGroup(group: UAObject) {
|
|
426
|
-
const trustList = group.getComponentByName("TrustList")
|
|
430
|
+
const trustList = group.getComponentByName("TrustList");
|
|
427
431
|
if (trustList) {
|
|
428
432
|
installAccessRestrictionOnTrustList(trustList);
|
|
429
433
|
}
|
|
@@ -447,8 +451,10 @@ export async function installPushCertificateManagement(
|
|
|
447
451
|
});
|
|
448
452
|
|
|
449
453
|
function install_method_handle_on_type(addressSpace: AddressSpace): void {
|
|
450
|
-
const serverConfigurationType = addressSpace.findObjectType(
|
|
451
|
-
|
|
454
|
+
const serverConfigurationType = addressSpace.findObjectType(
|
|
455
|
+
"ServerConfigurationType"
|
|
456
|
+
) as unknown as UAServerConfiguration | null;
|
|
457
|
+
if (!serverConfigurationType || serverConfigurationType.createSigningRequest.isBound()) {
|
|
452
458
|
return;
|
|
453
459
|
}
|
|
454
460
|
serverConfigurationType.createSigningRequest.bindMethod(_createSigningRequest);
|
|
@@ -462,13 +468,14 @@ export async function installPushCertificateManagement(
|
|
|
462
468
|
serverConfiguration.createSigningRequest.bindMethod(_createSigningRequest);
|
|
463
469
|
serverConfiguration.updateCertificate.bindMethod(_updateCertificate);
|
|
464
470
|
serverConfiguration.getRejectedList.bindMethod(_getRejectedList);
|
|
465
|
-
|
|
466
|
-
serverConfiguration.applyChanges!.bindMethod(_applyChanges);
|
|
467
|
-
}
|
|
471
|
+
serverConfiguration.applyChanges?.bindMethod(_applyChanges);
|
|
468
472
|
|
|
469
473
|
const cg = serverConfiguration.certificateGroups.getComponents();
|
|
470
474
|
|
|
471
|
-
const defaultApplicationGroup = serverConfiguration.certificateGroups.getComponentByName("DefaultApplicationGroup")
|
|
475
|
+
const defaultApplicationGroup = serverConfiguration.certificateGroups.getComponentByName("DefaultApplicationGroup");
|
|
476
|
+
if (!defaultApplicationGroup) {
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
472
479
|
const certificateTypes = defaultApplicationGroup.getPropertyByName("CertificateTypes") as UAVariable;
|
|
473
480
|
certificateTypes.setValueFromSource({
|
|
474
481
|
dataType: DataType.NodeId,
|
|
@@ -476,7 +483,10 @@ export async function installPushCertificateManagement(
|
|
|
476
483
|
value: [resolveNodeId(ObjectTypeIds.RsaSha256ApplicationCertificateType)]
|
|
477
484
|
});
|
|
478
485
|
|
|
479
|
-
const certificateGroupType = addressSpace.findObjectType("CertificateGroupType")
|
|
486
|
+
const certificateGroupType = addressSpace.findObjectType("CertificateGroupType");
|
|
487
|
+
if (!certificateGroupType) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
480
490
|
|
|
481
491
|
for (const certificateGroup of cg) {
|
|
482
492
|
if (certificateGroup.nodeClass !== NodeClass.Object) {
|