0
這是我第一次使用openssl簽署證書。繼續打上面的錯誤並嘗試realpath()並追加file://但仍然無法獲得openssl簽名配置文件。我不明白這是如何工作的。任何見解,將不勝感激。Openssl_pkcs7_sign():錯誤打開文件
編輯1:我不確定哪個文件是有問題的文件。錯誤消息不夠具體。有沒有辦法告訴?
代碼和下面截圖:
function signProfile()
{
$filename = "./template.mobileconfig";
$filename = realpath($filename);
$outFilename = $filename . ".tmp";
$pkey = dirname(__FILE__) . "/PteKey.key";
$pkey = realpath($pkey);
$certFile = dirname(__FILE__) . "/CertToSign.crt";
$certFile = realpath($certFile);
// try signing the plain XML profile
if (openssl_pkcs7_sign($filename, $outFilename, 'file://'.$certFile, array('file://'.$pkey, ""), array(), 0, ""))
{
// get the data back from the filesystem
$signedString = file_get_contents($outFilename);
// trim the fat
$trimmedString = preg_replace('/(.+\n)+\n/', '', $signedString, 1);
// convert to binary (DER)
$decodedString = base64_decode($trimmedString);
// write the file back to the filesystem (using the filename originally given)
$fh = fopen($filename, 'w');
fwrite($fh, $decodedString);
fclose($fh);
// delete the temporary file
unlink($outFilename);
return TRUE;
}
else
{
return FALSE;
}
}
隨意PM我,如果你碰到同樣的問題。 :) – f0rfun