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
b5a6b607
Commit
b5a6b607
authored
Oct 15, 2024
by
Roman Yurchak
Committed by
oroulet
Oct 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TST Add test to generate and load a private key
parent
47111216
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+1
-1
tests/test_gen_certificates.py
tests/test_gen_certificates.py
+11
-1
No files found.
asyncua/common/xmlimporter.py
View file @
b5a6b607
...
...
@@ -482,7 +482,7 @@ class XmlImporter:
self
.
_set_attr
(
sub_atttype
,
subargs
,
attname2
,
v2
)
if
"Encoding"
in
subargs
:
del
subargs
[
"Encoding"
]
fargs
[
attname
]
=
atttype
(
**
subargs
)
fargs
[
attname
]
=
atttype
(
**
subargs
)
# type: ignore[operator]
else
:
raise
RuntimeError
(
f"Could not handle type
{
atttype
}
of type
{
type
(
atttype
)
}
"
)
...
...
tests/test_gen_certificates.py
View file @
b5a6b607
...
...
@@ -6,7 +6,9 @@ from cryptography import x509
from
cryptography.x509.oid
import
ExtendedKeyUsageOID
,
NameOID
from
cryptography.hazmat.primitives.asymmetric.rsa
import
RSAPrivateKey
from
cryptography.x509.extensions
import
_key_identifier_from_public_key
as
key_identifier_from_public_key
from
asyncua.crypto.cert_gen
import
generate_private_key
,
generate_app_certificate_signing_request
,
generate_self_signed_app_certificate
,
sign_certificate_request
from
asyncua.crypto.uacrypto
import
load_private_key
from
asyncua.crypto.cert_gen
import
generate_private_key
,
generate_app_certificate_signing_request
,
generate_self_signed_app_certificate
,
sign_certificate_request
,
dump_private_key_as_pem
async
def
test_create_self_signed_app_certificate
()
->
None
:
...
...
@@ -198,3 +200,11 @@ async def test_app_sign_certificate_request() -> None:
assert
cert
.
extensions
.
get_extension_for_class
(
x509
.
ExtendedKeyUsage
).
value
==
csr
.
extensions
.
get_extension_for_class
(
x509
.
ExtendedKeyUsage
).
value
async
def
test_generate_load_private_key_pem
(
tmp_path
):
key_path
=
tmp_path
/
"cert.pem"
key
=
generate_private_key
()
key_path
.
write_bytes
(
dump_private_key_as_pem
(
key
))
key2
=
await
load_private_key
(
key_path
)
assert
dump_private_key_as_pem
(
key
)
==
dump_private_key_as_pem
(
key2
)
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