xref: /PHP-8.1/ext/openssl/tests/bug61930.phpt (revision 03a4ccd9)
1--TEST--
2Bug #61930: openssl corrupts ssl key resource when using openssl_get_publickey()
3--EXTENSIONS--
4openssl
5--FILE--
6<?php
7$cert = file_get_contents(__DIR__.'/public.crt');
8
9$data = <<<DATA
10Please verify me
11DATA;
12
13$sig = 'w45LtLoRY/WPk/kcmP6CwGysOMuxuLbD35xMB/iAe5IMiBJjz2D1WGEY7Vz+rLZmYqOo58qNC3VtTg6ge9+UhfQHplvs6cXGKm' .
14       'SkQlYv4EeFoByqYfPU9k2dE/WEItOJUUyqu9pHaCmRtLpxoLnJcdQVdiXfT0t8KwxUzZYDjrSfhp7rbKhhCc4jZMwo9PvBuPAT' .
15       'MEfZbRNaVpwCFpjmmJczZCHFZFm7JYzR2jU0sjJMGALXidNBs9p0Fi1TGz3pZkxnQ5lwI5DX5ZSY0jiOcoVFt7k29GVFd0DPjm' .
16       '1NyieYU6tpnanG+ZqHIT8Um3FajYh0x1iMMe2lLETjklqYiw==';
17
18$key = openssl_get_publickey($cert);
19var_dump(openssl_get_publickey($key));
20var_dump(openssl_verify($data, base64_decode($sig), $key, OPENSSL_ALGO_SHA256));
21?>
22--EXPECTF--
23object(OpenSSLAsymmetricKey)#%d (0) {
24}
25int(1)
26