|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-02 11:49 UTC] larry at smog dot com
When I try to use openssl_csr_sign to sign a CSR with a CA certificate I get no error reports, and program output terminates.
Example code:
$cacert = "file://caselfsigncert.pem";
$cakey = array("file://caselfsignkey.pem", "insecureselfsignkey");
if ($privkey = openssl_pkey_new()) {
openssl_pkey_export($privkey, $pkeyout, $passphrase);
print "<h2>priv key</h2><pre>$pkeyout</pre>";
}
if ($csr = openssl_csr_new($dn, $privkey)) {
openssl_csr_export($csr, $csrout);
print "<h2>CSR:</h2><pre>$csrout</pre>";
}
if ($cert = openssl_csr_sign($csr, $cacert, $cakey, 365)) {
openssl_x509_export($cert, $certout);
print "<h2>x509:</h2><pre>$certout</pre>";
}
I am certain that the $cacert and $cakey files are being properly opened. If I change them to reference an invalid file, PHP returns the appropriate errors. I'm also certain that the key's passphrase is being properly passed, when I change the passphrase I also get the expected errors.
In fact, OpenSSL returns success, but my program appears to exit. I've tried the openssl_error_string, but it also reports no information. I'm no PHP expert, but it appears as if PHP segfaulting when this function is called. Works fine if I call it with a NULL for the $cacert value (i.e. self-signed). Using the CA cert with the commandline tool openssl works fine too.
Using openssl-0.9.6h.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
Sorry for bothering you again, but here is the code: <? php $caCertFile = "root.pem"; $req_key = openssl_pkey_new(); openssl_pkey_export_to_file($req_key, "newkey.pem", $_POST[chlPassword]); if(openssl_pkey_export ($req_key, $out_key)) { $dn = array( "countryName" => $_POST[countryName], "stateOrProvinceName" => $_POST[stateName], "localityName" => $_POST[cityName], "organizationName" => $_POST[organizationName], "organizationalUnitName" => $_POST[unitName], "commonName" => $_POST[commonName], "emailAddress" => $_POST[emailAddress] ); $req_csr = openssl_csr_new ($dn, $req_key); openssl_csr_export_to_file($req_csr, "newreq.pem"); $req_cert = openssl_csr_sign($req_csr, "file://$caCertFile", $req_key, 1) ; ?> I know that root.pem exists, and it is being loaded, but it looks like the PHP engine just crashes at the openssl_csr_sign.