JoostBerkers
JoostBerkers

Reputation: 53

Connect with OPCUA server with Basic256Sha256 in Python

Te following code is used to connect with the opcua server:

from opcua import Client
client = Client(url='opc.tcp://192.168.0.5:4840')


client.set_user('user1')
client.set_password('password')
client.connect()

Error message:

Received an error: MessageAbort(error:StatusCode(BadSecurityPolicyRejected), reason:None) Protocol Error

I also tried to append this code:

client.set_security_string("Basic256Sha256,Sign,cert.pem,key.pem")

But I do not know where I can create de cert.pem and key.pem

Does anyone know how to connect with the server in python

Upvotes: 4

Views: 2560

Answers (1)

Schroeder
Schroeder

Reputation: 1134

You can use this script and adapt it to your needs: https://github.com/FreeOpcUa/python-opcua/blob/master/examples/generate_certificate.sh

Also python-opcua is deprecated. So if you start a new project, I would recommend you to use asyncua. Asyncua also has a sync wrapper if you don't want to deal with asyncio.

Upvotes: 3

Related Questions