Skip to content

Commit 635a6db

Browse files
committed
fix tests with minimal changes
1 parent f6c1b64 commit 635a6db

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

tests/test_x509.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import base64
66
import datetime
77
import subprocess
8+
import tempfile
89

910
from asn1crypto import pem
1011
from asn1crypto.csr import CertificationRequest, CertificationRequestInfo
@@ -223,13 +224,21 @@ def test_self_sign_certificate(self):
223224
}
224225
)
225226

226-
# Pipe our certificate to OpenSSL to verify it
227-
with subprocess.Popen(
228-
(OPENSSL, "verify"), stdin=subprocess.PIPE, stdout=subprocess.DEVNULL
229-
) as proc:
230-
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
231-
proc.stdin.close()
232-
self.assertEqual(proc.wait(), 0)
227+
pem_cert = pem.armor("CERTIFICATE", cert.dump())
228+
229+
with tempfile.NamedTemporaryFile(delete_on_close=False) as pem_file:
230+
pem_file.write(pem_cert)
231+
pem_file.close()
232+
233+
# Pipe our certificate to OpenSSL to verify it
234+
with subprocess.Popen(
235+
(OPENSSL, "verify", "-CAfile", pem_file.name),
236+
stdin=subprocess.PIPE,
237+
stdout=subprocess.DEVNULL,
238+
) as proc:
239+
proc.stdin.write(pem.armor("CERTIFICATE", cert.dump()))
240+
proc.stdin.close()
241+
self.assertEqual(proc.wait(), 0)
233242

234243
@Only.openssl
235244
@requires(Mechanism.RSA_PKCS_KEY_PAIR_GEN, Mechanism.SHA1_RSA_PKCS)

0 commit comments

Comments
 (0)