33import logging
44
55from cryptography import x509
6- from cryptography .hazmat .backends import default_backend
76from cryptography .hazmat .primitives import serialization
87from cryptography .hazmat .primitives .asymmetric import ec
98from cryptography .hazmat .primitives .asymmetric import rsa
@@ -22,7 +21,7 @@ def import_public_key_from_pem_file(filename):
2221 :return: A public key instance
2322 """
2423 with open (filename , "rb" ) as key_file :
25- public_key = serialization .load_pem_public_key (key_file .read (), backend = default_backend () )
24+ public_key = serialization .load_pem_public_key (key_file .read ())
2625 return public_key
2726
2827
@@ -35,9 +34,7 @@ def import_private_key_from_pem_file(filename, passphrase=None):
3534 :return: A private key instance
3635 """
3736 with open (filename , "rb" ) as key_file :
38- private_key = serialization .load_pem_private_key (
39- key_file .read (), password = passphrase , backend = default_backend ()
40- )
37+ private_key = serialization .load_pem_private_key (key_file .read (), password = passphrase )
4138 return private_key
4239
4340
@@ -56,7 +53,7 @@ def import_public_key_from_pem_data(pem_data):
5653 pem_data = bytes ("{}\n {}\n {}" .format (PREFIX , pem_data , POSTFIX ), "utf-8" )
5754 else :
5855 pem_data = bytes (pem_data , "utf-8" )
59- cert = x509 .load_pem_x509_certificate (pem_data , default_backend () )
56+ cert = x509 .load_pem_x509_certificate (pem_data )
6057 return cert .public_key ()
6158
6259
@@ -68,7 +65,7 @@ def import_public_key_from_cert_file(filename):
6865 :return: A public key instance
6966 """
7067 with open (filename , "rb" ) as key_file :
71- cert = x509 .load_pem_x509_certificate (key_file .read (), backend = default_backend () )
68+ cert = x509 .load_pem_x509_certificate (key_file .read ())
7269 return cert .public_key ()
7370
7471
@@ -81,7 +78,7 @@ def der_cert(der_data):
8178 """
8279 if isinstance (der_data , str ):
8380 der_data = bytes (der_data , "utf-8" )
84- return x509 .load_der_x509_certificate (der_data , default_backend () )
81+ return x509 .load_der_x509_certificate (der_data )
8582
8683
8784def load_x509_cert (url , httpc , spec2key , ** get_args ):
0 commit comments