[ 
https://issues.apache.org/jira/browse/TIKA-3784?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17550223#comment-17550223
 ] 

Nick Burch commented on TIKA-3784:
----------------------------------

We don't currently have any Mime Magic for PKCS12 files

Based on 
[https://stackoverflow.com/questions/33239875/jks-bks-and-pkcs12-file-formats] 
it won't be an easy one to cope with, since we don't currently have an ASN.1 
container detector

I think we can potentially get away with a slightly hacky approach similar to 
the PKCS7 signature, where we look for a few variants and hope the right entry 
comes first... "openssl asn1parse" should help with working out what to look for

(Assuming no-one has a bit of time to knock up an ASN1 container detector based 
on the BouncyCastle ASN.1 using an approach similar to 
[https://stackoverflow.com/questions/10190795/parsing-asn-1-binary-data-with-java]
 )

> Detector returns "application/x-x509-key" when scanning a .p12 file
> -------------------------------------------------------------------
>
>                 Key: TIKA-3784
>                 URL: https://issues.apache.org/jira/browse/TIKA-3784
>             Project: Tika
>          Issue Type: Bug
>          Components: detector
>    Affects Versions: 1.26
>            Reporter: Matthias Hofbauer
>            Priority: Critical
>
> We are using tika to check if the MIME type of the file extensions matches 
> with the MIME type of the file content.
> After our upgrade from tika-core 1.22 to 1.26 our logic does not work anymore 
> for certificates of type .p12, .pfx, .cer, .der.
> For the .p12 and .pfx extension the MIME type is "application/x-pkcs12" but 
> the tika detector returns "application/x-x509-key" instead.
> After checking the tika-mimetype.xml and comparing it to my .p12 file I found 
> the following MIME magic which explains why I got these types back.
> {code:xml}
> <mime-type type="application/x-x509-key;format=der">
>     <sub-class-of type="application/x-x509-key"/>
>     <!-- These are just a bunch of magic integers as defined by the key 
> format... -->
>     <!-- Always seem to have a version integer as their first entry, -->
>     <!--  normally 00, 01 or 02, check for that -->
>     <magic priority="40">
>       <match value="0x3081FF020100" type="string"
>               mask="0xFFFF00FFFFFC" offset="0"/>
>       <match value="0x3082FFFF020100" type="string"
>               mask="0xFFFF0000FFFFFC" offset="0"/>
>     </magic>
> </mime-type> {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to