Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
575305f1
Commit
575305f1
authored
Jan 05, 2016
by
Alexander Korolkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pretty-print server certificate in uadiscover
parent
03c3f4d7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
opcua/crypto/uacrypto.py
opcua/crypto/uacrypto.py
+17
-0
opcua/tools.py
opcua/tools.py
+12
-1
No files found.
opcua/crypto/uacrypto.py
View file @
575305f1
...
...
@@ -156,6 +156,23 @@ def p_sha1(secret, seed, sizes=()):
return
tuple
(
parts
)
def
x509_name_to_string
(
name
):
parts
=
[
"{}={}"
.
format
(
attr
.
oid
.
_name
,
attr
.
value
)
for
attr
in
name
]
return
', '
.
join
(
parts
)
def
x509_to_string
(
cert
):
"""
Convert x509 certificate to human-readable string
"""
if
cert
.
subject
==
cert
.
issuer
:
issuer
=
' (self-signed)'
else
:
issuer
=
', issuer: {}'
.
format
(
x509_name_to_string
(
cert
.
issuer
))
# TODO: show more information
return
"{}{}, {} - {}"
.
format
(
x509_name_to_string
(
cert
.
subject
),
issuer
,
cert
.
not_valid_before
,
cert
.
not_valid_after
)
if
__name__
==
"__main__"
:
# Convert from PEM to DER
cert
=
load_certificate
(
"../examples/server_cert.pem"
)
...
...
opcua/tools.py
View file @
575305f1
...
...
@@ -403,11 +403,22 @@ def application_to_strings(app):
return
result
# ['{}: {}'.format(n, v) for (n, v) in result]
def
cert_to_string
(
der
):
if
not
der
:
return
'[no certificate]'
try
:
from
opcua.crypto
import
uacrypto
except
ImportError
:
return
"{} bytes"
.
format
(
len
(
der
))
cert
=
uacrypto
.
x509_from_der
(
der
)
return
uacrypto
.
x509_to_string
(
cert
)
def
endpoint_to_strings
(
ep
):
result
=
[(
'Endpoint URL'
,
ep
.
EndpointUrl
)]
result
+=
application_to_strings
(
ep
.
Server
)
result
+=
[
(
'Server Certificate'
,
len
(
ep
.
ServerCertificate
)),
(
'Server Certificate'
,
cert_to_string
(
ep
.
ServerCertificate
)),
(
'Security Mode'
,
str
(
ep
.
SecurityMode
)),
(
'Security Policy URI'
,
ep
.
SecurityPolicyUri
)]
for
tok
in
ep
.
UserIdentityTokens
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment