node-opcua / opcua-commander

a opcua client with blessed (ncurses)
MIT License
211 stars 46 forks source link

Cannot read property 'join' of undefined #20

Closed jgentes closed 4 years ago

jgentes commented 5 years ago

When I run opcua-commander -e opc.tcp://localhost:62541 -u opcuauser -p opcuauser -P=Basic256Sha256 -s SIGNANDENCRYPT I get the error:

C:\dev\npm\node_modules\opcua-commander\index.js:75
    throw new Error("Invalid Security mode , should be " + opcua.MessageSecurityMode.enums.join(" "));
                                                                                           ^

TypeError: Cannot read property 'join' of undefined
    at Object.<anonymous> (C:\dev\npm\node_modules\opcua-commander\index.js:75:92)

I've tried Basic128Rsa15 as well. I'm connecting to a fresh Ignition OPC-UA server and I may not have it configured correctly, however this looks like a bug in opcua-commander unless I have the syntax incorrect.

Node version == 8.15.1

gboor commented 5 years ago

I just ran into the same issue. It looks like the referenced variable does not exist, so none of the -P or -s options work.

gboor commented 5 years ago

Update; I found that when I use values that are valid according to the node-opcua-client library (included below), it does work. There is, however, an error in the creation of the error message - funnily enough :P

opcua.MessageSecurityMode
{
  '0': 'Invalid',
  '1': 'None',
  '2': 'Sign',
  '3': 'SignAndEncrypt',
  Invalid: 0,
  None: 1,
  Sign: 2,
  SignAndEncrypt: 3
}

opcua.SecurityPolicy
{
  Invalid: 'invalid',
  None: 'http://opcfoundation.org/UA/SecurityPolicy#None',
  Basic128: 'http://opcfoundation.org/UA/SecurityPolicy#Basic128',
  Basic128Rsa15: 'http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15',
  Basic192: 'http://opcfoundation.org/UA/SecurityPolicy#Basic192',
  Basic192Rsa15: 'http://opcfoundation.org/UA/SecurityPolicy#Basic192Rsa15',
  Basic256: 'http://opcfoundation.org/UA/SecurityPolicy#Basic256',
  Basic256Rsa15: 'http://opcfoundation.org/UA/SecurityPolicy#Basic256Rsa15',
  Basic256Sha256: 'http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256',
  Aes128_Sha256_RsaOaep: 'http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep',
  PubSub_Aes128_CTR: 'http://opcfoundation.org/UA/SecurityPolicy#PubSub_Aes128_CTR',
  PubSub_Aes256_CTR: 'http://opcfoundation.org/UA/SecurityPolicy#PubSub_Aes256_CTR'
}

might differ on your specific release.

erossignon commented 4 years ago

you now need to run

opcua-commander -e opc.tcp://localhost:62541 -u opcuauser -p opcuauser -P=Basic256Sha256 -s SignAndEncrypt

note SIGNANDENCRYPT -> SignAndEncrypt