How to use the node-opcua-secure-channel.fromURI 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 / src / opcua_server.js View on Github external
function adjustSecurityPolicy(channel, userTokenPolicy_securityPolicyUri) {
    // check that userIdentityToken
    let securityPolicy = fromURI(userTokenPolicy_securityPolicyUri);

    // if the security policy is not specified we use the session security policy
    if (securityPolicy === SecurityPolicy.Invalid) {
        securityPolicy = fromURI(channel.clientSecurityHeader.securityPolicyUri);
        assert(securityPolicy);
    }
    return securityPolicy;
}
github node-opcua / node-opcua / packages / node-opcua-server / src / opcua_server.js View on Github external
function adjustSecurityPolicy(channel, userTokenPolicy_securityPolicyUri) {
    // check that userIdentityToken
    let securityPolicy = fromURI(userTokenPolicy_securityPolicyUri);

    // if the security policy is not specified we use the session security policy
    if (securityPolicy === SecurityPolicy.Invalid) {
        securityPolicy = fromURI(channel.clientSecurityHeader.securityPolicyUri);
        assert(securityPolicy);
    }
    return securityPolicy;
}
github node-opcua / node-opcua / packages / node-opcua-client / src / opcua_client.js View on Github external
* OPC Unified Architecture 1.0.4:  Part 4 155
     * Each UserIdentityToken allowed by an Endpoint shall have a UserTokenPolicy specified in the
     * EndpointDescription. The UserTokenPolicy specifies what SecurityPolicy to use when encrypting
     * or signing. If this SecurityPolicy is omitted then the Client uses the SecurityPolicy in the
     * EndpointDescription. If the matching SecurityPolicy is set to None then no encryption or signature
     * is required.
     *
     */
    const userTokenPolicy = findUserTokenPolicy(endpoint_desc, UserIdentityTokenType.USERNAME);

    // istanbul ignore next
    if (!userTokenPolicy) {
        throw new Error("Cannot find USERNAME user token policy in end point description");
    }

    let securityPolicy = fromURI(userTokenPolicy.securityPolicyUri);

    // if the security policy is not specified we use the session security policy
    if (securityPolicy === SecurityPolicy.Invalid) {
        securityPolicy = session._client._secureChannel.securityPolicy;
        assert(securityPolicy);
    }

    let identityToken;
    let serverCertificate = session.serverCertificate;
    // if server does not provide certificate use unencrypted password
    if (!serverCertificate) {
        identityToken = new UserNameIdentityToken({
            encryptionAlgorithm: null,
            password: Buffer.from(password, "utf-8"),
            policyId: userTokenPolicy ? userTokenPolicy.policyId : null,
            userName: userName,
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
function matching_endpoint(
  securityMode: MessageSecurityMode,
  securityPolicy: SecurityPolicy,
  endpointUrl: string | undefined,
  endpoint: EndpointDescription
): boolean {

    assert(endpoint instanceof EndpointDescription);
    const endpoint_securityPolicy = fromURI(endpoint.securityPolicyUri);
    if (endpointUrl && endpoint.endpointUrl! !== endpointUrl) {
        return false;
    }
    return (endpoint.securityMode === securityMode && endpoint_securityPolicy === securityPolicy);
}
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
function matching_endpoint(
  securityMode: MessageSecurityMode,
  securityPolicy: SecurityPolicy,
  endpointUrl: string | undefined,
  endpoint: EndpointDescription
): boolean {

    assert(endpoint instanceof EndpointDescription);
    const endpoint_securityPolicy = fromURI(endpoint.securityPolicyUri);
    if (endpointUrl && endpoint.endpointUrl! !== endpointUrl) {
        return false;
    }
    return (endpoint.securityMode === securityMode && endpoint_securityPolicy === securityPolicy);
}