Skip to content

Commit b206c44

Browse files
committed
fix tests with minimal changes
1 parent 4c51ab3 commit b206c44

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.github/workflows/tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
- "3.10"
1717
- "3.11"
1818
- "3.12"
19-
- "3.12"
2019
- "3.13"
2120

2221
steps:
@@ -51,6 +50,7 @@ jobs:
5150
run: |
5251
env
5352
softhsm2-util --version
53+
openssl version
5454
5555
- name: Initialize token
5656
run: softhsm2-util --init-token --free --label $PKCS11_TOKEN_LABEL --pin $PKCS11_TOKEN_PIN --so-pin $PKCS11_TOKEN_SO_PIN

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() as pem_file:
230+
pem_file.write(pem_cert)
231+
pem_file.flush()
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)