我想创建一个自签名证书。 请参阅 simplesamlphp 所需的证书:http://simplesamlphp.org/docs/stable/simplesamlphp-idp#section_7,如下所示
openssl req -newkey rsa:2048 -new -x509 -days 3652 -nodes
-out example.org.crt -keyout example.org.pem
我关注How to create a digital certificate and export to .p12 file in PHP?
<?php
$dn = array(
"countryName" => "UK",
"stateOrProvinceName" => "Somerset",
"localityName" => "Glastonbury",
"organizationName" => "The Brain Room Limited",
"organizationalUnitName" => "PHP Documentation Team",
"commonName" => "Wez Furlong",
"emailAddress" => "wez@example.com"
);
$privkey = openssl_pkey_new();
$csr = openssl_csr_new($dn, $privkey);
$sscert = openssl_csr_sign($csr, null, $privkey, 365);
openssl_csr_export($csr, $csrout) and var_dump($csrout);
openssl_x509_export($sscert, $certout) and var_dump($certout);
openssl_pkey_export($privkey, $pkeyout, "mypassword") and var_dump($pkeyout);
// Show any errors that occurred here
while (($e = openssl_error_string()) !== false) {
echo $e . "\n";
}
&GT;
我得到了输出:
string(749) "-----BEGIN CERTIFICATE REQUEST-----
MIIB7zCCAVgCAQAwga4xCzAJBgNVBAYTAlVLMREwDwYDVQQIEwhTb21lcnNldDEU
MBIGA1UEBxMLR2xhc3RvbmJ1cnkxHzAdBgNVBAoTFlRoZSBCcmFpbiBSb29tIExp
bWl0ZWQxHzAdBgNVBAsTFlBIUCBEb2N1bWVudGF0aW9uIFRlYW0xFDASBgNVBAMT
C1dleiBGdXJsb25nMR4wHAYJKoZIhvcNAQkBFg93ZXpAZXhhbXBsZS5jb20wgZ8w
DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAMIGCb4LaB9eS6nF8oijsPaYr7nEM0Vi
GdQwbqGdmyTA9TN+nvb3tIbdz7TAW8mrFzCyFv/32q0HNpU75x7HoVq19E9SP7EZ
FYPoCXYnjiWocoStb3zTvE7aXGPx60VNhRDy2RsXEnmO02McdIUDwP13SIXof2w1
xYwBc0aJczpdAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQCLn0cLtRc/lJBG4Z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EOqzfJqqVBDXKcBCyrNXqmtQn+SkWk4
j/w8+3Rc+FRAZL8ndPmoZRpvJUPR3K+NzLPdOnQ157srxNbh9ckRk0cTMIaAlhxn
+UqJUDeWBJX1qkDp4gG1gG11Nu2LoF/xfkScu0JG9xcev1Ib6auuJI82vau/6Q8w
qapNpTjUYVsc+aviz10mXCMwF2x5okSmzelHk4U42234XgCec6Gj6ml7fqkIS+P7
bHx1x9Ov8LLmnjZPHVv/p6Nqpb3j1IkEDDkZ8M1s5+Eky5gw9vDNdox3bZLEyEfL
OW7PXvfIggHmyfnsFyIfzdZGVfTSXv9Gsq/QMfbrXeRcGb9yEG5Hng==
-----END RSA PRIVATE KEY-----
"
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
error:0E06D06C:configuration file routines:NCONF_get_string:no value
我将$pkeyout
作为 server.pem 和$certout
作为 server.crt 。
但我收到错误:
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in
/var/www/sso/simplesamlphp/lib/xmlseclibs.php on line 478
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in
/var/www/sso/simplesamlphp/lib/xmlseclibs.php on line 478