above code should be corrected to:
$Destfile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Destfile;
Bu işlevlerin davranışı php.ini içindeki ayarlardan etkilenir.
İsim | Öntanımlı | Değişlik Yeri | Sürüm Bilgisi |
---|---|---|---|
openssl.cafile | "" | PHP_INI_PERDIR | |
openssl.capath | "" | PHP_INI_PERDIR |
Yapılandırma yönergelerinin kısa açıklamalarını aşağıda bulabilirsiniz.
openssl.cafile
string
Uzaktaki görevdeşin kimliğini doğrulamak için
verify_peer
bağlam seçeneğiyle kullanılması gereken
yerel dosya sistemindeki Sertifika Yetkilisi dosyasının konumu.
openssl.capath
string
cafile belirtilmezse veya sertifika orada yoksa capath ile gösterilen dizinde uygun bir sertifika aranır. capath, doğru şekilde aşlanmış bir sertifika dizini olmalıdır.
Ayrıca bkz. SSL bağlamı seçenekleri
above code should be corrected to:
$Destfile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Destfile;
in capath the Certificates must be placed with the certificates hash as name and .0 as Ending.
Here is how to get the hashes from Certificates lying in this folder and automatically rename them in a correct way:
<?php
$paths=openssl_get_cert_locations();
$allowed=array("cer","crt","pem");
if (!empty($paths['ini_capath'])){
$capathDirectory = dir($paths['ini_capath']);
while (false !== ($entry = $capathDirectory->read())) {
$Sourcefile=$paths['ini_capath']."/".$entry;
if (file_exists( $Sourcefile)){
$path_parts = pathinfo($Sourcefile);
if (in_array(strtolower($path_parts['extension']),$allowed)){
$ParsedCertificatePbject = openssl_x509_parse(file_get_contents($Sourcefile));
$Sourcefile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Sourcefile;
if (!file_exists($TargetFilename)) {
rename ($Sourcefile ,$TargetFilename);
}
}
}
}
$capathDirectory->close();
}
?>
Hashed directory bedeutet die Dateinamen müssen mit dem Openssl hash, den ihr mittels openssl_x509_parse im Wert hash bekommt (Name) + die Dateiendung 0.
Bei doppelten HASH werten wird die Dateiendung incrementiert.