Skip to content

Commit b8215d8

Browse files
committed
build(tests): Use x509.SubjectAlternativeName as instance
Refs: #131
1 parent cfba4c8 commit b8215d8

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

automatoes/acme.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,6 @@ def get_order_challenges(self, order: Order):
413413
:param order: order to be challenged
414414
:return: Order
415415
"""
416-
domains = [identifier['value'] for identifier in
417-
order.contents['identifiers']]
418416
order_challenges = []
419417
for auth in order.contents['authorizations']:
420418
auth_response = _json(self.post_as_get(auth, self.account.uri))
@@ -522,7 +520,7 @@ def post(self, path, body, headers=None, kid=None):
522520
protected = self.get_headers(url=self.path(path))
523521
if kid:
524522
protected['kid'] = kid
525-
protected.pop('jwk')
523+
protected.pop("jwk")
526524
body = sign_request_v2(self.account.key, protected, body)
527525
kwargs = {
528526
'headers': _headers
@@ -539,7 +537,7 @@ def post_as_get(self, path, kid, headers=None):
539537

540538
protected = self.get_headers(url=self.path(path))
541539
protected['kid'] = kid
542-
protected.pop('jwk')
540+
protected.pop("jwk")
543541
body = sign_request_v2(self.account.key, protected, None)
544542
kwargs = {
545543
'headers': _headers

automatoes/crypto.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
with warnings.catch_warnings():
2929
warnings.simplefilter("ignore")
3030
from cryptography import x509
31-
from cryptography.x509 import NameOID
31+
from cryptography.x509 import NameOID, DNSName, SubjectAlternativeName
3232
from cryptography.hazmat.backends import default_backend
3333
from cryptography.hazmat.primitives.asymmetric import padding
3434
from cryptography.hazmat.primitives.asymmetric.rsa import (
@@ -97,7 +97,7 @@ def generate_header(account_key):
9797
numbers = account_key.public_key().public_numbers()
9898
e = numbers.e.to_bytes((numbers.e.bit_length() // 8 + 1), byteorder='big')
9999
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
101101
n = n[1:]
102102
return {
103103
'alg': 'RS256',
@@ -178,7 +178,8 @@ def export_private_key(key):
178178
"""
179179
Exports a private key in OpenSSL PEM format.
180180
"""
181-
return key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL, NoEncryption())
181+
return key.private_bytes(Encoding.PEM, PrivateFormat.TraditionalOpenSSL,
182+
NoEncryption())
182183

183184

184185
def create_csr(key, domains, must_staple=False):
@@ -235,7 +236,7 @@ def get_issuer_certificate_domain_name(cert):
235236

236237
def get_certificate_domain_name(cert):
237238
for ext in cert.extensions:
238-
if isinstance(ext.value, SubjectAlternativeName):
239+
if isinstance(ext.value, x509.SubjectAlternativeName):
239240
return ext.value.get_values_for_type(DNSName)[0]
240241

241242

0 commit comments

Comments
 (0)