PHP: openssl_pkey_get_public - Manual

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

search for in the

openssl_pkey_new openssl_pkey_get_private

Last updated: Fri, 26 Jan 2007

view this page in

# openssl_pkey_get_public

(PHP 4 >= 4.2.0, PHP 5)

openssl_pkey_get_public -- Extract public key from certificate and prepare it for use

## Description

resource openssl_pkey_get_public ( mixed certificate )

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

openssl_get_publickey() extracts the public key from `certificate` and prepares it for use by other functions. `certificate` can be one of the following:

1. an X.509 certificate resource

2. 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).

3. A PEM formatted private key.

add a note User Contributed Notes
openssl_pkey_get_public
dankybastard at hotmail
09-Feb-2005 08:52
`You must also use the string representation of the certificate to get the public key resource:
$dn = array(); // use defaults
$res_privkey = openssl_pkey_new();
$res_csr = openssl_csr_new($dn, $res_privkey);
$res_cert = openssl_csr_sign($res_csr, null, $res_privkey, $ndays);
openssl_x509_export($res_cert, $str_cert);
$res_pubkey = openssl_pkey_get_public($str_cert);`
09-Aug-2004 11:44
`This documentation notes it can take a PEM-formatted private key, but as per bug #25614, this is not possible in any form. The function simply returns a FALSE.
The only thing you can get public keys out of are X.509 certificates.
Furthermore, there is NO way to export a public key into a PEM-encoded form.`
add a note
openssl_pkey_new openssl_pkey_get_private

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