Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: openssl_pkey_new - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

openssl_private_decrypt" width="11" height="7"/> <openssl_pkey_get_public
Last updated: Thu, 31 May 2007

view this page in

openssl_pkey_new

(PHP 4 >= 4.2.0, PHP 5)

openssl_pkey_new — 新規に秘密鍵を生成する

説明

resource openssl_pkey_new ( [array $configargs] )

openssl_pkey_new() は、新しい秘密鍵と公開鍵の 鍵ペアを作成します。鍵の公開部は、openssl_pkey_get_public() を使用して取得可能です。鍵の作成方法の詳細(ビット数など)を指定する には、configargs を使用します。 configargs の詳細な情報については openssl_csr_new() を参照ください。

注意: この関数を正しく機能させるには、有効な openssl.cnf がインストールされている必要があります。詳細な情報については インストールセクション の下にある注記を参照ください。



add a note add a note User Contributed Notes
openssl_pkey_new
NOSPAM dot alchaemist at hiperlinux dot com dot ar
30-May-2004 04:17
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.

 
show source | credits | sitemap | contact | advertising | mirror sites