|
28 | 28 | with warnings.catch_warnings():
|
29 | 29 | warnings.simplefilter("ignore")
|
30 | 30 | from cryptography import x509
|
31 |
| -from cryptography.x509 import NameOID |
| 31 | +from cryptography.x509 import NameOID, DNSName, SubjectAlternativeName |
32 | 32 | from cryptography.hazmat.backends import default_backend
|
33 | 33 | from cryptography.hazmat.primitives.asymmetric import padding
|
34 | 34 | from cryptography.hazmat.primitives.asymmetric.rsa import (
|
@@ -97,7 +97,7 @@ def generate_header(account_key):
|
97 | 97 | numbers = account_key.public_key().public_numbers()
|
98 | 98 | e = numbers.e.to_bytes((numbers.e.bit_length() // 8 + 1), byteorder='big')
|
99 | 99 | n = numbers.n.to_bytes((numbers.n.bit_length() // 8 + 1), byteorder='big')
|
100 |
| - if n[0] == 0: # for strict JWK |
| 100 | + if n[0] == 0: # for strict JWK |
101 | 101 | n = n[1:]
|
102 | 102 | return {
|
103 | 103 | 'alg': 'RS256',
|
@@ -178,7 +178,8 @@ def export_private_key(key):
|
178 | 178 | """
|
179 | 179 | Exports a private key in OpenSSL PEM format.
|
180 | 180 | """
|
181 |
| - return key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption()) |
| 181 | + return key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, |
| 182 | + NoEncryption()) |
182 | 183 |
|
183 | 184 |
|
184 | 185 | def create_csr(key, domains, must_staple=False):
|
@@ -235,7 +236,7 @@ def get_issuer_certificate_domain_name(cert):
|
235 | 236 |
|
236 | 237 | def get_certificate_domain_name(cert):
|
237 | 238 | for ext in cert.extensions:
|
238 |
| - if isinstance(ext.value, SubjectAlternativeName): |
| 239 | + if isinstance(ext.value, x509.SubjectAlternativeName): |
239 | 240 | return ext.value.get_values_for_type(DNSName)[0]
|
240 | 241 |
|
241 | 242 |
|
|
0 commit comments