note 96211 modified in function.openssl-pkey-get-public by danbrown
| From: | danbrown@php.net | Date: | Mon, 15 Feb 2010 15:50:55 +0000 |
| Subject: | note 96211 modified in function.openssl-pkey-get-public by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165972@lists.php.net to get a copy of this message | ||
Note this will read public keys from PEM formatted public keys as well:
<?php
$key = <<<EOF
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXX/MsKEBLcLeKA1d/i7ufG1qs
qS97xFkIRSeX3TwmHic843AfVrzoh2pZUeOvK9ZLZQpHSM7DoHMYDGD1273+FvZX
Ypf5LiFtecfxko/Cku16zy6WAeCYVFjjlveBhwPmPCIk+qDRYeiIW05QE2XK+CuD
nJ7sxxXIJSSgD3Jo5wIDAQAB
-----END PUBLIC KEY-----
EOF;
print $key;
$res = openssl_pkey_get_public($key);
print_r(openssl_pkey_get_details($res));
?>
Note that contrary to the documentation, openssl_pkey_get_details() will *not* read PEM directly,
and you have to go through this step.
--was--
Note this will read public keys from PEM formatted public keys as well:
<?
$key = <<<EOF
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXX/MsKEBLcLeKA1d/i7ufG1qs
qS97xFkIRSeX3TwmHic843AfVrzoh2pZUeOvK9ZLZQpHSM7DoHMYDGD1273+FvZX
Ypf5LiFtecfxko/Cku16zy6WAeCYVFjjlveBhwPmPCIk+qDRYeiIW05QE2XK+CuD
nJ7sxxXIJSSgD3Jo5wIDAQAB
-----END PUBLIC KEY-----
EOF;
print $key;
$res = openssl_pkey_get_public($key);
print_r(openssl_pkey_get_details($res));
?>
Note that contrary to the documentation, openssl_pkey_get_details() will *not* read PEM directly,
and you have to go through this step.
http://php.net/manual/en/function.openssl-pkey-get-public.php