How to use the node-opcua.MessageSecurityMode function in node-opcua

To help you get started, we’ve selected a few node-opcua 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 locka99 / opcua / 3rd-party / node-opcua / server.js View on Github external
/*global require,setInterval,console */
var opcua = require("node-opcua");

// Let's create an instance of OPCUAServer
var server = new opcua.OPCUAServer({
    securityPolicies: [opcua.SecurityPolicy.None, opcua.SecurityPolicy.Basic128Rsa15, opcua.SecurityPolicy.Basic256, opcua.SecurityPolicy.Basic256Sha256],
    securityModes: [opcua.MessageSecurityMode.NONE, opcua.MessageSecurityMode.SIGN, opcua.MessageSecurityMode.SIGNANDENCRYPT],
    port: 4855, // the port of the listening socket of the server
    resourcePath: "", // this path will be added to the endpoint resource name
    buildInfo: {
        productName: "Node OPCUA Server",
        buildNumber: "7658",
        buildDate: new Date(2014, 5, 2)
    },
    alternateHostname: "127.0.0.1"
});

function post_initialize() {
    console.log("initialized");

    function construct_my_address_space(server) {

        var addressSpace = server.engine.addressSpace;
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
.alias("p", "password")
    .alias("n", "node")
    .alias("t", "timeout")

    .alias("d", "debug")
    .alias("h", "history")
    .example("simple_client  --endpoint opc.tcp://localhost:49230 -P=Basic256 -s=SIGN")
    .example("simple_client  -e opc.tcp://localhost:49230 -P=Basic256 -s=SIGN -u JoeDoe -p P@338@rd ")
    .example("simple_client  --endpoint opc.tcp://localhost:49230  -n=\"ns=0;i=2258\"")

    .argv;


const securityMode = opcua.coerceMessageSecurityMode(argv.securityMode || "None");
if (!securityMode) {
    throw new Error("Invalid Security mode , should be " + opcua.MessageSecurityMode.enumItems.join(" "));
}

const securityPolicy = opcua.coerceSecurityPolicy(argv.securityPolicy || "None");
if (!securityPolicy) {
    throw new Error("Invalid securityPolicy , should be " + opcua.SecurityPolicy.enumItems.join(" "));
}

//xx argv.securityMode   = argv.securityMode || "SignAndEncrypt";
//xx argv.securityPolicy = argv.securityPolicy || "Basic128Rsa15";
const timeout = parseInt(argv.timeout) * 1000 || 20000;

const monitored_node = argv.node || "ns=1;s=PumpSpeed"; //"ns=1;s=Temperature";

console.log(chalk.cyan("securityMode        = "), securityMode.toString());
console.log(chalk.cyan("securityPolicy      = "), securityPolicy.toString());
console.log(chalk.cyan("timeout             = "), timeout ? timeout : " Infinity ");
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
.alias("u", "userName")
    .alias("p", "password")
    .alias("n", "node")
    .alias("t", "timeout")

    .alias("d", "debug")
    .alias("h", "history")
    .example("simple_client  --endpoint opc.tcp://localhost:49230 -P=Basic256Sha256 -s=SIGN")
    .example("simple_client  -e opc.tcp://localhost:49230 -P=Basic256Sha256 -s=SIGN -u JoeDoe -p P@338@rd ")
    .example("simple_client  --endpoint opc.tcp://localhost:49230  -n=\"ns=0;i=2258\"")

    .argv;



const securityMode = opcua.MessageSecurityMode.get(argv.securityMode || "NONE");
if (!securityMode) {
    throw new Error("Invalid Security mode , should be " + opcua.MessageSecurityMode.enums.join(" "));
}

const securityPolicy = opcua.SecurityPolicy.get(argv.securityPolicy || "None");
if (!securityPolicy) {
    throw new Error("Invalid securityPolicy , should be " + opcua.SecurityPolicy.enums.join(" "));
}

//xx argv.securityMode   = argv.securityMode || "SIGNANDENCRYPT";
//xx argv.securityPolicy = argv.securityPolicy || "Basic128Rsa15";
const timeout = parseInt(argv.timeout) * 1000 || 20000;

const monitored_node = argv.node || "ns=1;s=PumpSpeed"; //"ns=1;s=Temperature";

function constructFilename(filename) {
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client.js View on Github external
.alias("n", "node")
    .alias("t", "timeout")

    .alias("d", "debug")
    .alias("h", "history")
    .example("simple_client  --endpoint opc.tcp://localhost:49230 -P=Basic256Sha256 -s=SIGN")
    .example("simple_client  -e opc.tcp://localhost:49230 -P=Basic256Sha256 -s=SIGN -u JoeDoe -p P@338@rd ")
    .example("simple_client  --endpoint opc.tcp://localhost:49230  -n=\"ns=0;i=2258\"")

    .argv;



const securityMode = opcua.MessageSecurityMode.get(argv.securityMode || "NONE");
if (!securityMode) {
    throw new Error("Invalid Security mode , should be " + opcua.MessageSecurityMode.enums.join(" "));
}

const securityPolicy = opcua.SecurityPolicy.get(argv.securityPolicy || "None");
if (!securityPolicy) {
    throw new Error("Invalid securityPolicy , should be " + opcua.SecurityPolicy.enums.join(" "));
}

//xx argv.securityMode   = argv.securityMode || "SIGNANDENCRYPT";
//xx argv.securityPolicy = argv.securityPolicy || "Basic128Rsa15";
const timeout = parseInt(argv.timeout) * 1000 || 20000;

const monitored_node = argv.node || "ns=1;s=PumpSpeed"; //"ns=1;s=Temperature";

function constructFilename(filename) {
    return path.join(__dirname,"../",filename);
}