Skip to content

Commit 7fe9cee

Browse files
committed
Resolved suggested changes
1 parent cf638e7 commit 7fe9cee

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ssm/crypto.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,24 @@ def check_cert_key(certpath, keypath):
6969
OpenSSL.crypto.FILETYPE_PEM, cert
7070
)
7171
crypto_public_key = certificate.get_pubkey()
72-
public_key_bytes = OpenSSL.crypto.dump_publickey(
72+
certificate_public_key = OpenSSL.crypto.dump_publickey(
7373
OpenSSL.crypto.FILETYPE_PEM, crypto_public_key
7474
)
7575

76-
certificate_public_key = public_key_bytes.decode("utf-8")
77-
78-
except Exception as error:
79-
log.error(error)
76+
except OpenSSL.crypto.Error as error:
77+
log.exception(error)
8078
return False
8179

8280
try:
8381
private_key = OpenSSL.crypto.load_privatekey(
8482
OpenSSL.crypto.FILETYPE_PEM, key
8583
)
86-
public_key_bytes = OpenSSL.crypto.dump_publickey(
84+
private_public_key = OpenSSL.crypto.dump_publickey(
8785
OpenSSL.crypto.FILETYPE_PEM, private_key
8886
)
8987

90-
private_public_key = public_key_bytes.decode("utf-8")
91-
92-
except Exception as error:
93-
log.error(error)
88+
except OpenSSL.crypto.Error as error:
89+
log.exception(error)
9490
return False
9591

9692
return certificate_public_key.strip() == private_public_key.strip()

0 commit comments

Comments
 (0)