xref: /PHP-8.3/ext/openssl/tests/gh12489.phpt (revision 83a242ec)
1--TEST--
2GH-12489: Missing sigbio creation checking in openssl_cms_verify
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$infile = __DIR__ . "/plain.txt";
8$outfile = __DIR__ . "/out.cms";;
9$vout = $outfile . '.vout';
10
11$privkey = "file://" . __DIR__ . "/private_rsa_1024.key";
12$single_cert = "file://" . __DIR__ . "/cert.crt";
13$assoc_headers = array("To" => "test@test", "Subject" => "testing openssl_cms_sign()");
14$headers = array("test@test", "testing openssl_cms_sign()");
15
16var_dump(openssl_cms_sign($infile, $outfile, openssl_x509_read($single_cert), $privkey, $headers,
17             OPENSSL_CMS_DETACHED|OPENSSL_CMS_BINARY,OPENSSL_ENCODING_PEM));
18ini_set('open_basedir', __DIR__);
19var_dump(openssl_cms_verify($infile,OPENSSL_CMS_NOVERIFY|OPENSSL_CMS_DETACHED|OPENSSL_CMS_BINARY,
20         NULL, array(), NULL, $vout, NULL, "../test.cms", OPENSSL_ENCODING_PEM));
21var_dump(openssl_error_string());
22?>
23--CLEAN--
24<?php
25$outfile = __DIR__ . "/out.cms";;
26$vout = $outfile . '.vout';
27
28@unlink($outfile);
29@unlink($vout);
30?>
31--EXPECTF--
32bool(true)
33
34Warning: openssl_cms_verify(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (%s) in %s on line %d
35bool(false)
36bool(false)
37