我正在使用openssl命令使用PHP创建证书。我正在使用exec。当我给exec命令时,返回状态为1
,我回复了我在exec(OpenSSL statement)
中插入的任何内容并尝试了通过cmd并且它工作正常(生成证书)但是当我通过PHP exec运行它时它不起作用。任何可以帮助我的人。
感谢
答案 0 :(得分:0)
也许您可以更轻松地使用phpseclib, a pure PHP X.509 implementation?如何创建自签名证书的示例:
<?php
include('File/X509.php');
include('Crypt/RSA.php');
// create private key / x.509 cert for stunnel / website
$privKey = new Crypt_RSA();
extract($privKey->createKey());
$privKey->loadKey($privatekey);
$pubKey = new Crypt_RSA();
$pubKey->loadKey($publickey);
$pubKey->setPublicKey();
$subject = new File_X509();
$subject->setDNProp('id-at-organizationName', 'phpseclib demo cert');
//$subject->removeDNProp('id-at-organizationName');
$subject->setPublicKey($pubKey);
$issuer = new File_X509();
$issuer->setPrivateKey($privKey);
$issuer->setDN($subject->getDN());
$x509 = new File_X509();
//$x509->setStartDate('-1 month'); // default: now
//$x509->setEndDate('+1 year'); // default: +1 year
$result = $x509->sign($issuer, $subject);
echo "the stunnel.pem contents are as follows:\r\n\r\n";
echo $privKey->getPrivateKey();
echo "\r\n";
echo $x509->saveX509($result);
echo "\r\n";
?>