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).
openssl_pkey_get_private
(PHP 4 >= 4.2.0, PHP 5)
openssl_pkey_get_private — 秘密鍵を取得する
説明
openssl_get_privatekey() は key をパースし、他の関数で使用できるよう準備します。
パラメータ
- key
-
key は以下のいずれかです。
- file://path/to/file.pem 形式の文字列。 このファイルは、PEM エンコードされた証明書/秘密鍵である必要が あります(両方を含むことも可能です)。
- PEM フォーマットの秘密鍵。
- passphrase
-
指定されたキーが(パスフレーズを用いて)暗号化されている場合は、 オプションのパラメータ passphrase を使用する必要があります。
返り値
成功した場合に正のキーリソース ID、エラー時に FALSE を返します。
openssl_pkey_get_private
justin at gripwire dot com
30-Apr-2008 01:55
30-Apr-2008 01:55
Joel Barker
30-Aug-2005 09:03
30-Aug-2005 09: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 12:58
17-Jan-2003 12: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";
}
