PHP OpenSSL 可以生成私钥/公钥/证书对吗?
不知道PHP的OpenSSL扩展是否可以生成private/public密钥/证书对?
I wonder if PHP's OpenSSL extension can be used to generate private/public key/certificate pairs?
推荐答案
当然,使用 openssl_pkey_new
:
Sure, use openssl_pkey_new
:
$privateKey = openssl_pkey_new(array('private_key_bits' => 2048));
$details = openssl_pkey_get_details($privateKey);
$publicKey = $details['key'];
您可以使用 openssl_pkey_export
导出密钥或openssl_pkey_export_to_file
.
You can export the keys with openssl_pkey_export
or openssl_pkey_export_to_file
.
相关文章