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

To help you get started, we’ve selected a few node-opcua-service-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-secure-channel / source / client / client_secure_channel_layer.ts View on Github external
this._isOpened = false;
        this._transport = null;
        this._lastRequestId = 0;
        this.parent = options.parent;
        this.clientNonce = null; // will be created when needed

        this.protocolVersion = 0;

        this.messageChunker = new MessageChunker({
            derivedKeys: null
        });

        this.defaultSecureTokenLifetime = options.defaultSecureTokenLifetime || 30000;
        this.tokenRenewalInterval = options.tokenRenewalInterval || 0;

        this.securityMode = coerceMessageSecurityMode(options.securityMode);

        this.securityPolicy = coerceSecurityPolicy(options.securityPolicy);

        this.serverCertificate = options.serverCertificate ? options.serverCertificate : null;

        if (this.securityMode !== MessageSecurityMode.None) {
            assert(this.serverCertificate as any instanceof Buffer,
                "Expecting a valid certificate when security mode is not None");
            assert(this.securityPolicy !== SecurityPolicy.None,
                "Security Policy None is not a valid choice");
        }

        this.messageBuilder = new MessageBuilder({
            name: "client",
            privateKey: this.getPrivateKey() || undefined,
            securityMode: this.securityMode
github node-opcua / node-opcua / packages / node-opcua-secure-channel / source / message_builder.ts View on Github external
public setSecurity(securityMode: MessageSecurityMode, securityPolicy: SecurityPolicy) {
        assert(this.securityMode === MessageSecurityMode.Invalid, "security already set");
        this.securityPolicy = coerceSecurityPolicy(securityPolicy);
        this.securityMode = coerceMessageSecurityMode(securityMode);
        assert(this.securityPolicy !== SecurityPolicy.Invalid);
        assert(this.securityMode !== MessageSecurityMode.Invalid);
    }