Skip to content

Commit

Permalink
Fix openssl_x509_checkpurpose_basic.phpt
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cmb69 committed Dec 12, 2021
1 parent f533744 commit 98175fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 47 deletions.
10 changes: 9 additions & 1 deletion ext/openssl/tests/openssl_x509_checkpurpose_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0")
?>
--FILE--
<?php
include 'CertificateGenerator.inc';
$certificateGenerator = new CertificateGenerator();
$certificateGenerator->saveCaCert(__DIR__ . "/san-cert.pem");

$cert = "file://" . __DIR__ . "/cert.crt";
$bert = "file://" . __DIR__ . "/bug41033.pem";
$sert = "file://" . __DIR__ . "/san-cert.pem";
$cpca = __DIR__ . "/san-ca.pem";
$cpca = __DIR__ . "/san-cert.pem";
$utfl = __DIR__ . "/sni_server_uk.pem";
$rcrt = openssl_x509_read($cert);

Expand Down Expand Up @@ -84,6 +88,10 @@ var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpc
var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl));
?>
--CLEAN--
<?php
@unlink(__DIR__ . "/san-cert.pem");
?>
--EXPECT--
bool(false)
bool(false)
Expand Down
15 changes: 0 additions & 15 deletions ext/openssl/tests/san-ca.pem

This file was deleted.

31 changes: 0 additions & 31 deletions ext/openssl/tests/san-cert.pem

This file was deleted.

0 comments on commit 98175fc

Please sign in to comment.