Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in twin service when using x509 authentication #121

Closed
Tracked by #2005
mm-dlwe opened this issue Sep 27, 2019 · 3 comments
Closed
Tracked by #2005

Error in twin service when using x509 authentication #121

mm-dlwe opened this issue Sep 27, 2019 · 3 comments
Assignees
Labels
bug Something isn't working Web-Api

Comments

@mm-dlwe
Copy link

mm-dlwe commented Sep 27, 2019

Describe the bug
When using authentication data in combination authentication all operations return 401 Unauthorized. This happens with "UserName" as well as with "X509Certificate".

{
  "Result": 401,
  "Payload": "<valid jwt token>",
  "Message": "Response 401",
  "Data": {},
  "Source": "Microsoft.Azure.IIoT.Core",
  "HResult": -2146233088,
  "Exception": "MethodCallStatusException"
}

The twin module connects to the server and passes the auth data. the session is established. On executing a command the connection changes from Ready to Error:

[13:08:08 INF] Success - using publisher module 'publisher' (mcr.microsoft.com/iotedge/opc-publisher:latest) via methods.
[13:08:08 INF] Publisher connected!
[13:08:12 INF] 1: Endpoint opc.tcp://<Server>/ via opc.tcp://<Server>/ changed from Connecting to Ready
[13:09:01 INF] 1: Endpoint opc.tcp://<Server>/ via opc.tcp://<Server>/ changed from Ready to Error
[13:09:06 INF] 1: Endpoint opc.tcp://<Server>/ via opc.tcp://<Server>/ changed from Error to Ready

A wrong password shows a different error as expected:

[13:14:18 WRN] 2: Establishing unecrypted connection to opc.tcp://<Server>/.
[13:14:18 INF] 2: Creating session to opc.tcp://<Server>/ via opc.tcp://<Server>/.
[13:14:18 INF] New settings processed.
[13:14:18 INF] 2: BadUserAccessDenied creating session to opc.tcp://<Server>/ via opc.tcp://<Server>/ - retry.
[13:14:18 INF] 2: Endpoint opc.tcp://<Server>/ via opc.tcp://<Server>/ changed from Connecting to Error
[13:14:18 INF] 2: Try to connect to opc.tcp://<Server>/ via opc.tcp://<Server>/ in 1092 ms...
[13:14:19 WRN] 2: Establishing unecrypted connection to opc.tcp://<Server>/.
[13:14:19 INF] 2: Creating session to opc.tcp://<Server>/ via opc.tcp://<Server>/.
[13:14:19 INF] 2: BadUserAccessDenied creating session to opc.tcp://<Server>/ via opc.tcp://<Server>/ - retry.
[13:14:19 INF] 2: Try to connect to opc.tcp://<Server>/ via opc.tcp://<Server>/ in 3453 ms...
[13:14:23 WRN] 2: Establishing unecrypted connection to opc.tcp://<Server>/.
[13:14:23 INF] 2: Creating session to opc.tcp://<Server>/ via opc.tcp://<Server>.
[13:14:28 INF] 2: BadRequestTimeout creating session to opc.tcp://<Server>/ via opc.tcp://<Endpoint> - retry.
[13:14:28 INF] 2: Endpoint opc.tcp://<Server>/ via opc.tcp://<Server> changed from Error to NotReachable
[13:14:28 INF] 2: Try to connect to opc.tcp://<Server>/ via opc.tcp://<Server> in 300000 ms...

To Reproduce
Steps to reproduce the behavior:

  1. Discover an opc ua server
  2. Update the endpoint with authentication data
  3. Activate the endpoint
  4. Call for example "Browse" on the endpoint
  5. See error
@marcschier
Copy link
Collaborator

Hi @mm-dlwe, can you provide more info around the server you are trying to access. Also, an example request json with a sample user name password so I can build a test around it? The access denied appears to point to an issue with how the credential is passed to the server. Assuming the password is correct.

@marcschier marcschier self-assigned this Sep 29, 2019
@marcschier marcschier added bug Something isn't working feature request New feature or request labels Sep 29, 2019
@mm-dlwe
Copy link
Author

mm-dlwe commented Oct 11, 2019

Sure the server is the UACppServer Demo from Unified automation configured to accept authentication using X509 Certificates. I use this request for publishing a node in the twin server API:

{
  "item": {
    "nodeId": "ns=2;s=Demo.Dynamic.Arrays.Boolean",
    "publishingInterval": 10000,
    "samplingInterval": 10000
  },
  "header": {
    "elevation": {
      "type": "X509Certificate",
      "value": "MIIKsQIBAzCCCncGCSqGSIb3DQEHAaCCCmgEggpkMIIKYDCCBRcGCSqGSIb3DQEHBqCCBQgwggUE
AgEAMIIE/QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI2I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wa0t4F22gTlRipY3udvRj9Vwd/zC
J1MUWPYjKCro40iNZK8VG6LmaPXK6JrFA7FmzbVSLdy+gkGcnOdwFHf2vbRdrLyH9oM4pUVdFJ2y
/y8Ba03l1Nvgjfxr+vYz5rlllRcXASrjQPU/Eo/G+8rDdbob5MneOYswDCPlxJ8DJPegr5UXOovy
A2NJbb08cREK/GOjkurx7qH01tjZqSYulyx89h8xJTAjBgkqhkiG9w0BCRUxFgQUe+AWiKoq/tlA
WH4tCabM6JL4iUwwMTAhMAkGBSsOAwIaBQAEFE6oMKZbxk6LATi0GsrYk0gN+W8WBAjGs6Xo9rGw
2wICCAA="
    }
  }
}

I put the test certificate in here as well so that yout can test with it (its a base64 encoded pfx). Wheter I use header.elevation or not does not matter. The authentication data was set using update enpoint information as well to get thje endpoint activation working.

The certificate is correctly whitelisted in the UaCPPServer and connections using UaExpert with the same certificate are working.

For user name password test we use the codesys opcua server of a WAGO PFC200. Which is a bit strange because it requires username and password to be send unencrypted.
But I would at least expect to get the UaCPPServer working.

@marcschier marcschier changed the title Error in twin service when using authentication Error in twin service when using x509 authentication Mar 29, 2020
@marcschier marcschier added this to the 3.0 milestone May 19, 2020
@barnstee barnstee removed this from the 3.0 milestone Sep 17, 2020
@hansgschossmann hansgschossmann removed the feature request New feature or request label May 11, 2021
@marcschier marcschier added this to the Future milestone Jan 17, 2023
@marcschier marcschier removed this from the Future milestone Jun 25, 2023
@marcschier
Copy link
Collaborator

Capability to use certificates for user auth in OPC Publisher 2.9* will be tracked in #2005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Web-Api
Projects
None yet
Development

No branches or pull requests

4 participants