above code should be corrected to:
$Destfile= $ParsedCertificatePbject["hash"].".0";
$TargetFilename = dirname($Sourcefile)."/".$Destfile;
Le comportement de ces fonctions est affecté par la configuration dans le fichier php.ini.
Nom | Défaut | Modifiable | Historique |
---|---|---|---|
openssl.cafile | "" | PHP_INI_PERDIR | |
openssl.capath | "" | PHP_INI_PERDIR |
Voici un éclaircissement sur l'utilisation des directives de configuration.
openssl.cafile
string
Emplacement du fichier Certificate Authority sur le système de fichier local qui devrait être utilisé avec l'option de contexte verify_peer pour authentifier l'identité du pair distant.
openssl.capath
string
Si cafile n'est pas spécifié ou si le certificat n'y est pas trouvé, le dossier pointé par capath est fouillé pour un certificat convenable. capath doit être un répertoire de certificat correctement haché.
Voir aussi les options du contexte de flux SSL.
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.