<?php
$opensslConfigPath
=
"D:\phpstudy\PHPTutorial\Apache\conf\openssl.cnf"
;
$config
=
array
(
"digest_alg"
=>
"sha512"
,
"private_key_bits"
=>2048,
"private_key_type"
=> OPENSSL_KEYTYPE_RSA,
'config'=>
$opensslConfigPath
);
$res
= openssl_pkey_new(
$config
);
openssl_pkey_export(
$res
,
$privkey
, null,
$config
);
$pubKey
= openssl_pkey_get_details(
$res
)['key'];
print_r(
$privkey
);
echo
'<p style=
"height:100px;background:red"
>1</p>';
print_r(
$pubKey
);
file_put_contents
('
private
.key',
$privkey
);
file_put_contents
('
public
.key',
$pubKey
);
?>