0
기존 .csr 파일의 phpseclib를 사용하여 자체 서명 된 인증서를 만들 수있는 방법은 .csr 파일 만 사용할 수 있습니다.phpseclib을 사용하여 자체 서명 된 인증서를 만드는 방법
설명서를 읽었는데 그 방법은 개인 키를 사용하지만, 과제에서는 .csr 파일 만 사용할 수 있습니다.
도와 주시면 감사하겠습니다. 당신은 개인 키, 평범하고 단순해야합니다
<?php
include('File/X509.php');
include('Crypt/RSA.php');
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
//This is the content of the file
$csr = file_get_contents($_FILES["file"]["name"]);
}
// 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->loadCSR('...'); // see csr.pem
// calling setPublicKey() is unnecessary when loadCSR() is called
$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";
?>