Commit b137217 1 parent cdde969 commit b137217 Copy full SHA for b137217
File tree 3 files changed +10
-14
lines changed
3 files changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -157,8 +157,7 @@ def add_pem_cert_header_footer(pem_cert: bytes) -> bytes:
157
157
"""
158
158
pem_value_str = pem_cert .decode ('ascii' )
159
159
# note: it would be great if 'add_pem_header' did not forcefully convert bytes to str.
160
- mod_pem_value_str = signxml .util .add_pem_header (pem_value_str )
161
- mod_pem_value : bytes = mod_pem_value_str .encode ('ascii' )
160
+ mod_pem_value : bytes = signxml .util .add_pem_header (pem_value_str )
162
161
return mod_pem_value
163
162
164
163
Original file line number Diff line number Diff line change @@ -440,14 +440,8 @@ def verify_xml_signature(
440
440
)
441
441
442
442
if isinstance (trusted_x509_cert , crypto_utils ._X509CertOpenSsl ):
443
- trusted_x509_cert_open_ssl = trusted_x509_cert
444
- elif isinstance (trusted_x509_cert , crypto_utils .X509Cert ):
445
- trusted_x509_cert_open_ssl = crypto_utils ._X509CertOpenSsl .from_cryptography (
446
- trusted_x509_cert
447
- )
448
- elif trusted_x509_cert is None :
449
- trusted_x509_cert_open_ssl = None
450
- else :
443
+ trusted_x509_cert = trusted_x509_cert .to_cryptography ()
444
+ elif not isinstance (trusted_x509_cert , (crypto_utils .X509Cert , type (None ))):
451
445
# A 'crypto_utils._X509CertOpenSsl' is ok but we prefer 'crypto_utils.X509Cert'.
452
446
raise TypeError ("'trusted_x509_cert' must be a 'crypto_utils.X509Cert' instance, or None." )
453
447
@@ -482,7 +476,7 @@ def verify_xml_signature(
482
476
result = xml_verifier .verify (
483
477
data = tmp_bytes ,
484
478
require_x509 = True ,
485
- x509_cert = trusted_x509_cert_open_ssl ,
479
+ x509_cert = trusted_x509_cert ,
486
480
ignore_ambiguous_key_info = True ,
487
481
expect_config = signxml .verifier .SignatureConfiguration (
488
482
signature_methods = frozenset ([signxml .algorithms .SignatureMethod .RSA_SHA1 ]),
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ def test_fail_verify_with_other_cert(self) -> None:
221
221
verify_xml_signature (xml_doc , trusted_x509_cert = cert )
222
222
self .assertEqual (
223
223
cm .exception .args ,
224
- ("Signature verification failed: wrong signature length " ,),
224
+ ("Signature verification failed: " ,),
225
225
)
226
226
227
227
def test_bad_cert_included (self ) -> None :
@@ -251,7 +251,10 @@ def test_fail_replaced_cert(self) -> None:
251
251
verify_xml_signature (xml_doc , trusted_x509_cert = cert )
252
252
self .assertEqual (
253
253
cm .exception .args ,
254
- ("Signature verification failed: []" ,),
254
+ (
255
+ 'Invalid input.' ,
256
+ 'DER encoded key value does not match specified signature algorithm' ,
257
+ ),
255
258
)
256
259
257
260
def test_fail_included_cert_not_from_a_known_ca (self ) -> None :
@@ -262,7 +265,7 @@ def test_fail_included_cert_not_from_a_known_ca(self) -> None:
262
265
verify_xml_signature (xml_doc , trusted_x509_cert = None )
263
266
self .assertEqual (
264
267
cm .exception .args ,
265
- ('unable to get local issuer certificate ' ,),
268
+ ('validation failed: cert is not valid at validation time ' ,),
266
269
)
267
270
268
271
def test_fail_signed_data_modified (self ) -> None :
You can’t perform that action at this time.
0 commit comments