Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb7af29

Browse filesBrowse files
committed
add client-with-encryption.py example
1 parent 797abf1 commit eb7af29
Copy full SHA for eb7af29

2 files changed

+27Lines changed: 27 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎examples/client-with-encryption.py‎

Copy file name to clipboard
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import sys
2+
sys.path.insert(0, "..")
3+
import logging
4+
5+
from IPython import embed
6+
7+
from opcua import Client
8+
9+
10+
if __name__ == "__main__":
11+
logging.basicConfig(level=logging.WARNING)
12+
client = Client("opc.tcp://localhost:4840/freeopcua/server/")
13+
#client = Client("opc.tcp://localhost:53530/OPCUA/SimulationServer/")
14+
client.set_security_string("Basic256Sha256,SignAndEncrypt,certificate-example.der,private-key-example.pem")
15+
client.application_uri = "urn:example.org:FreeOpcUa:python-opcua"
16+
client.secure_channel_timeout = 10000
17+
client.session_timeout = 10000
18+
try:
19+
client.connect()
20+
root = client.get_root_node()
21+
objects = client.get_objects_node()
22+
print("childs og objects are: ", objects.get_children())
23+
24+
embed()
25+
finally:
26+
client.disconnect()
Collapse file

‎examples/server-with-encryption.py‎

Copy file name to clipboardExpand all lines: examples/server-with-encryption.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
server = Server()
1313
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
1414

15+
server.set_security_policy([ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt])
1516
# load server certificate and private key. This enables endpoints
1617
# with signing and encryption.
1718
server.load_certificate("certificate-example.der")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.