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

search for in the

openssl_private_decrypt> <openssl_pkey_get_public
[edit] Last updated: Fri, 23 Mar 2012

view this page in

openssl_pkey_new

(PHP 4 >= 4.2.0, PHP 5)

openssl_pkey_newYeni bir anahtar çifti üretir

Açıklama

resource openssl_pkey_new ([ array $ayarlar ] )

Yeni bir gizli/genel anahtar çifti üretir. Üretilen çiftin genel anahtarını openssl_pkey_get_public() işleviyle alabilirsiniz.

Bilginize: Bu işlevin gerektiği gibi çalışması için geçerli bir openssl.cnf kurulu olmalıdır. Daha ayrıntılı bilgi için kurulum bölümüne bakınız.

Değiştirgeler

ayarlar

Anahtar üretimine ince ayar çekmek için (bit sayısını belirtmek gibi) kullanılabilir. Daha ayrıntılı bilgi için openssl_csr_new()işlevine bakınız.

Dönen Değerler

İşlem başarısız olursa FALSE yoksa anahtar çifti için bir özkaynak tanıtıcısı döner.



openssl_private_decrypt> <openssl_pkey_get_public
[edit] Last updated: Fri, 23 Mar 2012
 
add a note add a note User Contributed Notes openssl_pkey_new
jthijssen at notloxic dot nl 10-Feb-2011 11:17
If you want to change the default private key size (1024) too something else you can use the following code:
 
<?php
$config
= array('private_key_bits' => 512);
$privKey = openssl_pkey_new($config);

?>

Mind though that the minimum number of bits is 384. Any lower will trigger an error.
Brad 02-Apr-2008 06:17
It's easier than all that, if you just want the keys:

<?php
// Create the keypair
$res=openssl_pkey_new();

// Get private key
openssl_pkey_export($res, $privkey);

// Get public key
$pubkey=openssl_pkey_get_details($res);
$pubkey=$pubkey["key"];
?>
NOSPAM dot alchaemist at hiperlinux dot com dot ar 29-May-2004 06: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 | stats | sitemap | contact | advertising | mirror sites