How to use the node-opcua-common.makeApplicationUrn function in node-opcua-common

To help you get started, we’ve selected a few node-opcua-common 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-client / src / opcua_client.js View on Github external
// get applicationURI from certificate
    const exploreCertificate = require("node-opcua-crypto").exploreCertificate;

    const certificate = this.getCertificate();
    let applicationUri;
    if (certificate) {
        const e = exploreCertificate(certificate);
        if (!e.tbsCertificate.extensions  || !e.tbsCertificate.extensions.subjectAltName) {
            console.log(chalk.red(" Warning: client certificate is invalid : subjectAltName is missing"));
            applicationUri = makeApplicationUrn(hostname, this.applicationName);
        } else {
            applicationUri = e.tbsCertificate.extensions.subjectAltName.uniformResourceIdentifier[0];
        }
    } else {
        applicationUri = makeApplicationUrn(hostname, this.applicationName);
    }
    return applicationUri;

};
github node-opcua / node-opcua / packages / node-opcua-server-discovery / src / opcua_discovery_server.js View on Github external
constructor(options) {

        const default_certificate_file = constructFilename("certificates/server_selfsigned_cert_2048.pem");
        options.certificateFile = options.certificateFile || default_certificate_file;
        assert(fs.existsSync(options.certificateFile));

        const default_private_key_file = constructFilename("certificates/PKI/own/private/private_key.pem");
        options.privateKeyFile = options.privateKeyFile || default_private_key_file;
        assert(fs.existsSync(options.certificateFile));

        const defaultApplicationUri = makeApplicationUrn(get_fully_qualified_domain_name(), "NodeOPCUA-DiscoveryServer");

        super(options);

        const serverInfo = options.serverInfo || {};

        serverInfo.applicationType = ApplicationType.DiscoveryServer;
        serverInfo.applicationUri = serverInfo.applicationUri || defaultApplicationUri;
        serverInfo.productUri = serverInfo.productUri || "SampleDiscoveryServer";
        serverInfo.applicationName = serverInfo.applicationName || {text: "SampleDiscoveryServer", locale: null};
        serverInfo.gatewayServerUri = serverInfo.gatewayServerUri || "";
        serverInfo.discoveryProfileUri = serverInfo.discoveryProfileUri || "";
        serverInfo.discoveryUrls = serverInfo.discoveryUrls || [];

        this.serverInfo = serverInfo;

        const port = options.port || 4840;
github node-opcua / node-opcua / packages / node-opcua-server-discovery / source / opcua_discovery_server.ts View on Github external
constructor(options: OPCUADiscoveryServerOptions) {

        const default_certificate_file = constructFilename("certificates/server_selfsigned_cert_2048.pem");
        options.certificateFile = options.certificateFile || default_certificate_file;
        assert(fs.existsSync(options.certificateFile));

        const default_private_key_file = constructFilename("certificates/PKI/own/private/private_key.pem");
        options.privateKeyFile = options.privateKeyFile || default_private_key_file;
        assert(fs.existsSync(options.certificateFile));

        const defaultApplicationUri = makeApplicationUrn("%FQDN%", "NodeOPCUA-DiscoveryServer");

        options.serverInfo = options.serverInfo || {};
        const serverInfo = options.serverInfo;
        serverInfo.applicationType = ApplicationType.DiscoveryServer;
        serverInfo.applicationUri = serverInfo.applicationUri || defaultApplicationUri;
        serverInfo.productUri = serverInfo.productUri || "NodeOPCUA-DiscoveryServer";
        serverInfo.applicationName = serverInfo.applicationName || { text: "NodeOPCUA-DiscoveryServer", locale: null };
        serverInfo.gatewayServerUri = serverInfo.gatewayServerUri || "";
        serverInfo.discoveryProfileUri = serverInfo.discoveryProfileUri || "";
        serverInfo.discoveryUrls = serverInfo.discoveryUrls || [];

        super(options);

        this.bonjourHolder = new BonjourHolder();

        const port = options.port || 4840;