Skip to content

Commit 98175fc

Browse files
committed
Fix openssl_x509_checkpurpose_basic.phpt
This test fails because san-cert.pem and san-ca.pem have expired. We fix that by using the CertificateGenerator to generate temporary certs during the test run. Since san-cert.pem and san-ca.pem have been identical, we only generate one certificate. Closes GH-7763.
1 parent f533744 commit 98175fc

File tree

3 files changed

+9
-47
lines changed

3 files changed

+9
-47
lines changed

ext/openssl/tests/openssl_x509_checkpurpose_basic.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0")
88
?>
99
--FILE--
1010
<?php
11+
include 'CertificateGenerator.inc';
12+
$certificateGenerator = new CertificateGenerator();
13+
$certificateGenerator->saveCaCert(__DIR__ . "/san-cert.pem");
14+
1115
$cert = "file://" . __DIR__ . "/cert.crt";
1216
$bert = "file://" . __DIR__ . "/bug41033.pem";
1317
$sert = "file://" . __DIR__ . "/san-cert.pem";
14-
$cpca = __DIR__ . "/san-ca.pem";
18+
$cpca = __DIR__ . "/san-cert.pem";
1519
$utfl = __DIR__ . "/sni_server_uk.pem";
1620
$rcrt = openssl_x509_read($cert);
1721

@@ -84,6 +88,10 @@ var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpc
8488
var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
8589
var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl));
8690
?>
91+
--CLEAN--
92+
<?php
93+
@unlink(__DIR__ . "/san-cert.pem");
94+
?>
8795
--EXPECT--
8896
bool(false)
8997
bool(false)

ext/openssl/tests/san-ca.pem

Lines changed: 0 additions & 15 deletions
This file was deleted.

ext/openssl/tests/san-cert.pem

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)