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

search for in the

openssl_pkey_get_public> <openssl_pkey_get_details
[edit] Last updated: Fri, 17 May 2013

view this page in

openssl_pkey_get_private

(PHP 4 >= 4.2.0, PHP 5)

openssl_pkey_get_privateObtener una clave privada

Descripción

resource openssl_pkey_get_private ( mixed $key [, string $passphrase = "" ] )

openssl_get_privatekey() analiza la clave key y la prepara para usarla con otras funciones.

Parámetros

key

key puede ser una de las siguientes:

  1. una cadena con el formato file://ruta/al/archivo.pem. El archivo nombrado debe contener un certificado/clave privada PEM codificada (puede contener ambos).
  2. una clave privada con formato PEM.

passphrase

El parámetro opcional passphrase se debe usar si la clave especificada está encriptada (protegida por una frase de contraseña).

Valores devueltos

Devuelve un identificador de clave positivo si se tuvo éxito, o FALSE si se produjo un error.



openssl_pkey_get_public> <openssl_pkey_get_details
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes openssl_pkey_get_private - [4 notes]
up
0
joelhy
2 years ago
Please note that "file://path/to/file.pem" in documentation means file protocol + file path. In UNIX like OS, that is something like file:///rsa_private_key.pem. There is THREE slashes in the path string, not TWO.
up
-1
justin at gripwire dot com
5 years ago
At least as of PHP 5.2.5, this function's prototype matches what is given on this page (i.e. it does not require an array for its two parameters).
up
-1
Joel Barker
7 years ago
Note that the important part of meint's post is that there is a SINGLE argument: an ARRAY of two elements. In other words, the correct prototype of the function is

resource openssl_pkey_get_private ( array params )

where params = array( 0 => $key, 1 => $passphrase)

Thanks, meint, you made my day!
up
-1
meint dot post at bigfoot dot com
10 years ago
Trying for hours to get openssl_pkey_get_private to load my private key (no problems with openssl_pkey_get_public) I found that the following loaded the private key correctly:

$passphrase="test";
$priv_key_file_name = ("./private.pem");

if (openssl_pkey_get_private(array("file://$priv_key_file_name", $passphrase)))
{
        print "\nPrivate Key OK\n\n";
} else {
        print "\nPrivate key NOT OK\n\n";
}

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