File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -124,8 +124,6 @@ def test_compressed_certificate(session):
124124 certificate ,
125125 compress = True ,
126126 )
127- assert certobj .get_certificate () == compressed_certobj .get_certificate (
128- decompress = True
129- )
127+ assert certobj .get_certificate () == compressed_certobj .get_certificate ()
130128 assert certobj .get () != compressed_certobj .get ()
131129 assert len (certobj .get ()) > len (compressed_certobj .get ())
Original file line number Diff line number Diff line change @@ -369,6 +369,7 @@ def put_certificate(
369369 :param domains: The set of domains to assign the object to.
370370 :param capabilities: The set of capabilities to give the object.
371371 :param certificate: A certificate to import.
372+ :param compress: (optional) Compress the certificate.
372373 :return: A reference to the newly created object.
373374 """
374375 encoded_cert = certificate .public_bytes (Encoding .DER )
@@ -384,14 +385,17 @@ def put_certificate(
384385 encoded_cert ,
385386 )
386387
387- def get_certificate (self , decompress : bool = False ) -> x509 .Certificate :
388+ def get_certificate (self ) -> x509 .Certificate :
388389 """Read an Opaque object from the YubiHSM, parsed as a certificate.
389390
390391 :return: The certificate stored for the object.
391392 """
392393 cert_data = self .get ()
393- if decompress :
394+ try :
395+ # Try to decompress cert
394396 cert_data = gzip .decompress (cert_data )
397+ except gzip .BadGzipFile :
398+ pass
395399 return x509 .load_der_x509_certificate (cert_data , default_backend ())
396400
397401
You can’t perform that action at this time.
0 commit comments