You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ni...@apache.org on 2020/09/29 16:07:37 UTC
[tika] 03/05: Add some more DER magic for certificates,
and add tests TIKA-3205
This is an automated email from the ASF dual-hosted git repository.
nick pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git
commit eaa712f89d5de9ad06647fa29d10ac1baa47a4c0
Author: Nick Burch <ni...@gagravarr.org>
AuthorDate: Tue Sep 29 16:23:08 2020 +0100
Add some more DER magic for certificates, and add tests TIKA-3205
---
.../org/apache/tika/mime/tika-mimetypes.xml | 28 ++++++++++++++++++----
.../java/org/apache/tika/mime/TestMimeTypes.java | 11 +++++++++
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
index 3cdea61..630b429 100644
--- a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
+++ b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
@@ -4639,10 +4639,16 @@
<match value="-----BEGIN CERTIFICATE-----" type="string" offset="0"/>
<!-- DER encoded -->
<match value="0x3080" type="string"
- mask="0xFFFC" offset="0">
- <!-- TODO other algs -->
- <match value="0x300d06092a864886f70d01010b0500"
- type="string" offset="10:50" />
+ mask="0xFFF8" offset="0">
+ <!-- SHA with RSA Encryption -->
+ <match value="0x300d06092a864886f70d01010b0500" type="string"
+ mask="0xFFFFFFFFFFFFFFFFFFFFFFFF00FFFF" offset="10:50" />
+ <!-- SHA with DSA Encryption -->
+ <match value="0x300b0609608648016503040301" type="string"
+ mask="0xFFFFFFFFFFFFFFFFFFFFFFFF00" offset="10:50" />
+ <!-- SHA with ECDSA Encryption -->
+ <match value="0x300a06082a8648ce3d040301" type="string"
+ mask="0xFFFFFFFFFFFFFFFFFFFFFF00" offset="10:50" />
</match>
</magic>
</mime-type>
@@ -4650,8 +4656,20 @@
<magic priority="50">
<!-- PEM encoded -->
<match value="-----BEGIN PRIVATE KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN PUBLIC KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN RSA KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN RSA PRIVATE KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN DSA KEY-----" type="string" offset="0"/>
+ <match value="-----BEGIN DSA PRIVATE KEY-----" type="string" offset="0"/>
<!-- DER encoded -->
- <!-- TODO -->
+ <match value="0x3082025e0201" type="string" offset="0"/>
+ </magic>
+ </mime-type>
+ <mime-type type="application/x-x509-dsa-parameters">
+ <magic priority="50">
+ <!-- PEM encoded -->
+ <match value="-----BEGIN DSA PARAMETERS-----" type="string" offset="0"/>
</magic>
</mime-type>
diff --git a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
index 83f67eb..a80dc8e 100644
--- a/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
+++ b/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
@@ -1136,6 +1136,17 @@ public class TestMimeTypes {
}
@Test
+ public void testCertificatesKeys() throws Exception {
+ assertType("application/x-x509-cert", "testCERT.pem");
+ assertType("application/x-x509-cert", "testCERT.der");
+ assertTypeByData("application/x-x509-cert", "testCERT.pem");
+ assertTypeByData("application/x-x509-cert", "testCERT.der");
+ // Keys need the data to identify, name isn't enough
+ assertTypeByData("application/x-x509-key", "testRSAKEY.pem");
+ assertTypeByData("application/x-x509-key", "testRSAKEY.der");
+ }
+
+ @Test
public void testVandICalendars() throws Exception {
assertType("text/calendar", "testICalendar.ics");
assertType("text/x-vcalendar", "testVCalendar.vcs");