PHP: openssl_pkey_get_private - Manual

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

search for in the

openssl_pkey_get_public openssl_pkey_free

Last updated: Fri, 26 Jan 2007

view this page in

# openssl_pkey_get_private

(PHP 4 >= 4.2.0, PHP 5)

openssl_pkey_get_private -- Get a private key

## Description

resource openssl_pkey_get_private ( mixed key [, string passphrase] )

Returns a positive key resource identifier on success, or `FALSE` on error.

openssl_get_privatekey() parses `key` and prepares it for use by other functions. `key` can be one of the following:

1. a string having the format `file://path/to/file.pem`. The named file must contain a PEM encoded certificate/private key (it may contain both).

2. A PEM formatted private key.

The optional parameter `passphrase` must be used if the specified key is encrypted (protected by a passphrase).

add a note User Contributed Notes
openssl_pkey_get_private
Joel Barker
30-Aug-2005 12:03
`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!`
meint dot post at bigfoot dot com
17-Jan-2003 03:58
`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";
}`
add a note
openssl_pkey_get_public openssl_pkey_free

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST