How to use the node-opcua-secure-channel.coerceSecurityPolicy function in node-opcua-secure-channel

To help you get started, we’ve selected a few node-opcua-secure-channel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-server / source / register_server_manager.ts View on Github external
assert(this.server!.serverType !== undefined,
          " must have a valid server Type");

        // construct connection
        const server = this.server!;
        const selectedEndpoint = this.selectedEndpoint;

        if (!selectedEndpoint) {
            console.log("Warning : cannot register server - no endpoint available");
            return outer_callback(new Error("Cannot registerServer"));
        }

        const options = {
            securityMode: selectedEndpoint.securityMode,
            securityPolicy: coerceSecurityPolicy(selectedEndpoint.securityPolicyUri),
            serverCertificate: selectedEndpoint.serverCertificate,

            certificateFile: server.certificateFile,
            privateKeyFile: server.privateKeyFile,

            clientName: "RegistrationClient-2",
            connectionStrategy: no_reconnect_connectivity_strategy
        };

        const client = OPCUAClientBase.create(options);

        const tmp = this._serverEndpoints;
        (client as any)._serverEndpoints = tmp;
        (server as any)._registration_client = client;

        const theStatus = isOnline
github node-opcua / node-opcua / packages / node-opcua-server / src / register_server_manager.js View on Github external
assert(self.selectedEndpoint || "must have a selected endpoint => please call _establish_initial_connection");
    assert(self.server.serverType !== undefined, " must have a valid server Type");
    assert(self.discoveryServerEndpointUrl);

    // construct connection
    const server = this.server;
    const selectedEndpoint = self.selectedEndpoint;

    if (!selectedEndpoint) {
        console.log("Warning : cannot register server - no endpoint avaialble");
        return outer_callback(new Error("Cannot registerServer"));
    }

    const options = {
        securityMode: selectedEndpoint.securityMode,
        securityPolicy: coerceSecurityPolicy(selectedEndpoint.securityPolicyUri),
        serverCertificate: selectedEndpoint.serverCertificate,
        certificateFile: server.certificateFile,
        privateKeyFile: server.privateKeyFile,
        connectionStrategy: no_reconnect_connectivity_strategy,
        clientName: "RegistrationClient-2"
    };

    const tmp = self._serverEndpoints;

    let client = OPCUAClientBase.create(options);
    client._serverEndpoints = tmp;
    server._registration_client = client;

    const theStatus =isOnline ? RegisterServerManagerStatus.REGISTERING :RegisterServerManagerStatus.UNREGISTERING;
    self._setState(theStatus);