依赖于OpenSSL扩展
"sha512","private_key_bits" => 4096,//字节数 512 1024 2048 4096 等
"private_key_type" => OPENSSL_KEYTYPE_RSA,//加密类型
);
$res = openssl_pkey_new($config);
if($res == false) return false;
openssl_pkey_export($res,$private_key);
$public_key = openssl_pkey_get_details($res);
$public_key = $public_key["key"];
file_put_contents(DATA_PATH."/conf/cert_public.key",$public_key);
file_put_contents(DATA_PATH."/conf/cert_private.pem",$private_key);
openssl_free_key($res);
}
原文链接:https://www.f2er.com/php/18037.html