xref: /PHP-8.0/ext/openssl/tests/bug61930.phpt (revision 9f44eca6)
1--TEST--
2Bug #61930: openssl corrupts ssl key resource when using openssl_get_publickey()
3--SKIPIF--
4<?php
5if (!extension_loaded("openssl")) die("skip");
6?>
7--FILE--
8<?php
9$cert = file_get_contents(__DIR__.'/cert.crt');
10
11$data = <<<DATA
12Please verify me
13DATA;
14
15$sig = 'f9Gyb6NV/ENn7GUa37ygTLcF93XHf5fbFTnoYF/O+fXbq3iChGUbET0RuhOsptl' .
16        'AODi6JsDLnJO4ikcVZo0tC1fFTj3LyCuPy3ZdgJbbVxQ/rviROCmuMFTqUW/Xa2' .
17        'LQYiapeCCgLQeWTLg7TM/BoHEkKbKLG/XT5jHvep1758A=';
18
19$key = openssl_get_publickey($cert);
20var_dump(openssl_get_publickey($key));
21var_dump(openssl_verify($data, base64_decode($sig), $key));
22?>
23--EXPECTF--
24object(OpenSSLAsymmetricKey)#%d (0) {
25}
26int(1)
27