Re: the function openssl_get_publickey() 's result is diferrent in php 7 and php5. 6.16 and php5.5.12 ???? so what is wrong?????

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 16 mar 2016 kl. 11:29 skrev v-LeonHou <764436364@xxxxxx>:
> 
> hi everyone,
> 
> today i meet a strange  while the function openssl_get_publickey()  runs well in php 7 while report an error in php5. 6.16 and php5.5.12
> 
> 
> here is the test code:
> 
> 
> <?php
> 
> 
> //define a  pem formatted string varaible named $key
> $key = <<<EOF
> -----BEGIN PUBLIC KEY-----
> MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXmKKMiFYnkd6rAoprih3/PrQEB/VsW8OoM8fxn67UDYuyBTqA23MML9q1+ilIZwBC2AQ2UBVOrFXfFl75p6/B5KsiNG9zpgmLCUYuLkxpLQIDAQAB
> -----END PUBLIC KEY-----
> EOF;
> 
> 
> //get the 
> $res = openssl_get_publickey($key); 
> var_dump($res);
> 
> 
> 
> ?>
> 
> 
> 
> 
> while in php7.0.0  the result is normal and correct  here is the output
> {
>    D:\wamp64\www\php\index.php(50) : eval()'d code:24:resource(4, OpenSSL key)
> }
> 
> 
> but not the same result in php 5.6.16 and php 5.5.12 here is the output
> {
>    D:\wamp64\www\php\index.php(50) : eval()'d code:24:boolean false
> }
> 
> 
> so can you help me  with the problem???
> 
> 
> thanks……..

Hi.

What type of public key are you using? The OpenSSL implementation seems to have some issues with PKCS#1 RSA public keys. Please read the user comment about openssl_get_publickey about this issue (http://php.net/manual/en/function.openssl-pkey-get-public.php#101513).

I strongly suggest to have a look at the error message from OpenSSL (openssl_error_string).

/frank


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux