note 42800 added to function.openssl-pkey-new
| From: | NOSPAM dot alchaemist at hiperlinux dot com dot ar | Date: | Sun, 30 May 2004 04:17:25 +0000 |
| Subject: | note 42800 added to function.openssl-pkey-new | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70291@lists.php.net to get a copy of this message | ||
As you probably found, getting the public key is not as direct as you might think with this
documentation.
You can easily get into messages like:
Warning: openssl_pkey_get_public(): Don't know how to get public key from this private key (the
documentation lied) in D:\www\keys.php on line 4
The correct steps to get the whole thing seem to be these:
<?
$dn = array("countryName" => 'XX', "stateOrProvinceName" =>
'State', "localityName" => 'SomewhereCity',
"organizationName" => 'MySelf', "organizationalUnitName" =>
'Whatever', "commonName" => 'mySelf', "emailAddress"
=> 'user@domain.com');
$privkeypass = '1234';
$numberofdays = 365;
$privkey = openssl_pkey_new();
$csr = openssl_csr_new($dn, $privkey);
$sscert = openssl_csr_sign($csr, null, $privkey, $numberofdays);
openssl_x509_export($sscert, $publickey);
openssl_pkey_export($privkey, $privatekey, $privkeypass);
openssl_csr_export($csr, $csrStr);
echo $privatekey; // Will hold the exported PriKey
echo $publickey; // Will hold the exported PubKey
echo $csrStr; // Will hold the exported Certificate
?>
Now all you need to do is to make some research on each individual function.
----
Manual Page -- http://www.php.net/manual/en/function.openssl-pkey-new.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42800
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42800&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42800&report=yes
Search -- http://master.php.net/manage/user-notes.php