S/MIME import from signature use BEGIN PKCS7

This commit is contained in:
the-djmaze 2024-02-26 22:34:15 +01:00
parent 20daa1ce13
commit 97b65465e2
2 changed files with 15 additions and 2 deletions

View file

@ -142,7 +142,7 @@ trait SMime
$sBody = \trim($sBody);
$certificates = [];
\openssl_pkcs7_read(
"-----BEGIN CERTIFICATE-----\n\n{$sBody}\n-----END CERTIFICATE-----",
"-----BEGIN PKCS7-----\n\n{$sBody}\n-----END PKCS7-----",
$certificates
) || \error_log("OpenSSL openssl_pkcs7_read: " . \openssl_error_string());
foreach ($certificates as $certificate) {
@ -179,7 +179,7 @@ trait SMime
$sBody = \trim($sBody);
$certificates = [];
\openssl_pkcs7_read(
"-----BEGIN CERTIFICATE-----\n\n{$sBody}\n-----END CERTIFICATE-----",
"-----BEGIN PKCS7-----\n\n{$sBody}\n-----END PKCS7-----",
$certificates
);

View file

@ -142,6 +142,19 @@ class OpenSSL
}
}
/*
public function asn1parse(/*string|Temporary* / $input) : ?string
{
if (\is_string($input)) {
$tmp = new Temporary('smimein-');
if (!$tmp->putContents($input)) {
return null;
}
$input = $tmp;
}
`openssl asn1parse -in $input->filename()`
}
*/
public function decrypt(/*string|Temporary*/ $input) : ?string
{
if (\is_string($input)) {