Skip to content

Commit

Permalink
Fix dict typing for older python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bitkeeper committed Jul 19, 2023
1 parent 4471607 commit 697c8a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions asyncua/crypto/cert_gen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
crypothelper contains helper functions to isolate the lower level cryto stuff from the GDS client.
"""

from typing import Dict
import datetime

from cryptography import x509
Expand All @@ -16,11 +16,11 @@
ONE_DAY = datetime.timedelta(1, 0, 0)
""" Shorthand for delta of 1 day """

OID_NAME_MAP: dict[str, x509.ObjectIdentifier] = {name: oid for oid, name in OID_NAMES.items()}
OID_NAME_MAP: Dict[str, x509.ObjectIdentifier] = {name: oid for oid, name in OID_NAMES.items()}
""" Create lookup table for x509.ObjectIdentifier based on textual name, by swapping key<>value of the available mapping"""


def _names_to_nameattributes(names: dict[str, str]) -> list[x509.NameAttribute]:
def _names_to_nameattributes(names: Dict[str, str]) -> list[x509.NameAttribute]:
"""Convert a dict with key/value of an x509.NameAttribute list
Args:
Expand Down Expand Up @@ -59,7 +59,7 @@ def dump_private_key_as_pem(private_key: rsa.RSAPrivateKey) -> bytes:

def generate_self_signed_app_certificate(private_key: rsa.RSAPrivateKey,
common_name: str,
names: dict[str, str],
names: Dict[str, str],
subject_alt_names: list[x509.GeneralName],
extended: list[x509.ObjectIdentifier],
days: int = 365) -> x509.Certificate:
Expand Down Expand Up @@ -137,7 +137,7 @@ def generate_self_signed_app_certificate(private_key: rsa.RSAPrivateKey,

def generate_app_certificate_signing_request(private_key: rsa.RSAPrivateKey,
common_name: str,
names: dict[str, str],
names: Dict[str, str],
subject_alt_names: list[x509.GeneralName],
extended: list[x509.ObjectIdentifier]
) -> x509.CertificateSigningRequest:
Expand Down
3 changes: 2 additions & 1 deletion examples/generate_certificates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" Example of several certficate creation helpers"""
from typing import Dict
import asyncio
from pathlib import Path
import socket
Expand All @@ -14,7 +15,7 @@
HOSTNAME: str = socket.gethostname()

# used for subject common part
NAMES: dict[str, str] = {
NAMES: Dict[str, str] = {
'countryName': 'NL',
'stateOrProvinceName': 'ZH',
'localityName': 'Foo',
Expand Down

0 comments on commit 697c8a8

Please sign in to comment.