Skip to content

Commit

Permalink
fix tests with minimal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Dec 27, 2024
1 parent f6c1b64 commit 635a6db
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import base64
import datetime
import subprocess
import tempfile

from asn1crypto import pem
from asn1crypto.csr import CertificationRequest, CertificationRequestInfo
Expand Down Expand Up @@ -223,13 +224,21 @@ def test_self_sign_certificate(self):
}
)

# Pipe our certificate to OpenSSL to verify it
with subprocess.Popen(
(OPENSSL, "verify"), stdin=subprocess.PIPE, stdout=subprocess.DEVNULL
) as proc:
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
proc.stdin.close()
self.assertEqual(proc.wait(), 0)
pem_cert = pem.armor("CERTIFICATE", cert.dump())

with tempfile.NamedTemporaryFile(delete_on_close=False) as pem_file:
pem_file.write(pem_cert)
pem_file.close()

# Pipe our certificate to OpenSSL to verify it
with subprocess.Popen(
(OPENSSL, "verify", "-CAfile", pem_file.name),
stdin=subprocess.PIPE,
stdout=subprocess.DEVNULL,
) as proc:
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
proc.stdin.close()
self.assertEqual(proc.wait(), 0)

@Only.openssl
@requires(Mechanism.RSA_PKCS_KEY_PAIR_GEN, Mechanism.SHA1_RSA_PKCS)
Expand Down

0 comments on commit 635a6db

Please sign in to comment.