Chaned some error_log() to MailSo Logger()

This commit is contained in:
the-djmaze 2024-02-27 02:31:53 +01:00
parent 182f884374
commit 847d33abc6
3 changed files with 8 additions and 5 deletions

View file

@ -81,7 +81,7 @@ trait Pgp
if (\is_link($link) || \symlink($homedir, $link)) {
$homedir = $link;
} else {
\error_log("symlink('{$homedir}', '{$link}') failed");
$this->logWrite("symlink('{$homedir}', '{$link}') failed", \LOG_WARNING, 'GnuPG');
}
}
// Else try ~/.gnupg/ + hash(email address)

View file

@ -142,7 +142,7 @@ trait SMime
\openssl_pkcs7_read(
"-----BEGIN PKCS7-----\n\n{$sBody}\n-----END PKCS7-----",
$certificates
) || \error_log("OpenSSL openssl_pkcs7_read: " . \openssl_error_string());
) || $this->logWrite("openssl_pkcs7_read: " . \openssl_error_string(), \LOG_ERR, 'OpenSSL');
foreach ($certificates as $certificate) {
$this->SMIME()->storeCertificate($certificate);
}

View file

@ -34,12 +34,15 @@ class OpenSSL
{
$data = \openssl_x509_parse(\openssl_x509_read($certificate));
if (!$data) {
\error_log("OpenSSL parse: " . \openssl_error_string());
\SnappyMail\Log::error('OpenSSL', "parse: " . \openssl_error_string());
return false;
}
$key = \str_replace(':', '', $data['extensions']['subjectKeyIdentifier'] ?? $data['hash']);
$filename = "{$this->homedir}/{$key}.crt";
if (!\file_exists($filename)) {
if (\file_exists($filename)) {
\SnappyMail\Log::debug('OpenSSL', 'certificate already imported');
} else {
\SnappyMail\Log::debug('OpenSSL', 'certificate imported');
\file_put_contents("{$this->homedir}/{$key}.crt", $certificate);
// \unlink("{$this->homedir}/certificates.json");
$this->certificates(true);
@ -98,7 +101,7 @@ class OpenSSL
}
$result[] = $short;
} else {
\error_log("OpenSSL parse({$file}): " . \openssl_error_string());
\SnappyMail\Log::error('OpenSSL', "parse({$file}): " . \openssl_error_string());
}
}
\file_put_contents($cacheFile, \json_encode($result));