File: openssl_x509_verify.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (45 lines) | stat: -rw-r--r-- 1,092 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--TEST--
openssl_x509_verify() tests
--EXTENSIONS--
openssl
--FILE--
<?php

$certFile = __DIR__ . '/openssl-x509-verify-cert.pem.tmp';
$keyFile = __DIR__ . '/openssl-x509-verify-key.pem.tmp';

include 'CertificateGenerator.inc';
$certificateGenerator = new CertificateGenerator(true);
$certificateGenerator->saveNewCertAndPubKey('openssl-x509-verify-server', $certFile, $keyFile);

$fp = fopen($certFile,"r");
$a = fread($fp, 8192);
fclose($fp);

$fp = fopen($keyFile,"r");
$b = fread($fp, 8192);
fclose($fp);

$cert = "file://" . $certFile;
$key = "file://" . $keyFile;
$wrongKey = "file://" . __DIR__ . "/public_rsa_2048.key";

var_dump(openssl_x509_verify($cert, $key));
var_dump(openssl_x509_verify("", $key));
var_dump(openssl_x509_verify($cert, ""));
var_dump(openssl_x509_verify("", ""));
var_dump(openssl_x509_verify(openssl_x509_read($a), $b));
var_dump(openssl_x509_verify($cert, $wrongKey));
?>
--CLEAN--
<?php
@unlink(__DIR__ . '/openssl-x509-verify-cert.pem.tmp');
@unlink(__DIR__ . '/openssl-x509-verify-key.pem.tmp');
?>
--EXPECT--
int(1)
int(-1)
int(-1)
int(-1)
int(1)
int(0)