[
https://issues.apache.org/jira/browse/TIKA-4999?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132627#comment-18132627
]
Tim Allison commented on TIKA-4999:
-----------------------------------
AFAICT, there's no reliable way to magic your way to a correct detection. You
need parsing.
The current mime detection is designed to funnel the file to the pkcs parser
that does the finer grained detection.
We do offer a workaround for those only doing detection, which is to add a
custom pkcs detector (basically the parser):
See:
[https://github.com/apache/tika/blob/main/docs/modules/ROOT/pages/configuration/detectors.adoc]
and
[https://github.com/apache/tika/blob/main/tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/resources/config-examples/detector-pkcs7.json]
> Certs-only PKCS#7 (.p7b) detected as application/pkcs7-signature instead of
> application/x-pkcs7-certificates
> -------------------------------------------------------------------------------------------------------------
>
> Key: TIKA-4999
> URL: https://issues.apache.org/jira/browse/TIKA-4999
> Project: Tika
> Issue Type: Bug
> Components: tika-core
> Reporter: Subbu
> Priority: Major
>
> Issue:
> A certificates-only PKCS#7 file (a .p7b bundle with no signers and no
> content) is detected by content as _application/pkcs7-signature._
> Cause:
> The application/pkcs7-signature magic matches only the outer wrapper, a DER
> ContentInfo with the signedData OID. Certs-only bundles and real signatures
> share that wrapper
> Fix:
> Add a magic rule to application/x-pkcs7-certificates at priority 60, above
> the signature rule's 50. It matches the signedData wrapper, then requires an
> empty digestAlgorithms set (31 00). A real signature has at least one digest
> algorithm, so it doesn't match.
> A test in Pkcs7DetectionTest uses existing content.
> testPKCS7_certs_only_def.p7c is detected as x-pkcs7-certificates by content.
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)