Hi im having a problem with a cron job with a php script, the answer the cron job is giving me is: "file cer.pem doesn't exists" however the file is in the same folder that the cron.php file im calling the file with the next code:
$params = array(
"cadenaOriginal" => "cadenaOriginal.txt",
"archivoKeyPem" => "key.pem",
"archivoCerPem" => "cer.pem"
);
try {
$result = Sellar::ObtenerSello($params);
return $result;
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "
";
}
but im getting the mentioned error this is the "ObtenerSello" funtion:
public static function ObtenerSello($params) {
self::_checkOpenssl();
if(isset($params['cadenaOriginal']) && isset($params['archivoCerPem']) && isset($params['archivoKeyPem'])){
$cadena_original = $params['cadenaOriginal'];
$archivoCerPem = $params['archivoCerPem'];
$archivoKeyPem = $params['archivoKeyPem'];
}else{
throw new Exception('Se debe especificar una cadena original, archivo .cer.pem, archivo .key.pem');
}
self::_existsFile($cadena_original);
self::_existsFile($archivoCerPem);
self::_existsFile($archivoKeyPem);
$cadena_original = file_get_contents($cadena_original);
$pkeyid = openssl_get_privatekey(file_get_contents($archivoKeyPem));
openssl_sign($cadena_original, $crypttext, $pkeyid, OPENSSL_ALGO_SHA256);
openssl_free_key($pkeyid);
$sello = base64_encode($crypttext);
if(!self::_verifySeal($cadena_original, $crypttext, $archivoCerPem)){
throw new Exception('Ocurrió un error al generar el sello.');
}
$r = ["status"=>"success", "sello"=>$sello];
return json_encode($r);
}`private static function _existsFile($file){
if(!file_exists($file)){
throw new Exception("El archivo $file no existe");
}
}`
all the files with this functions are in the same folder than cron.php but i keep getting the same error i already tried to put the path "../cron/cer.pem" but it says that "file ../cron/cer.pem doesn't exists" what am i doing wrong?? Thanks!!