Skip to content

Commit 0eca67e

Browse files
committed
Revert "TIKA-1997 -- pkcs detection"
This reverts commit ffd488e.
1 parent ffd488e commit 0eca67e

33 files changed

Lines changed: 38 additions & 706 deletions

File tree

CHANGES.txt

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
Release 4.0.0 - ???
2-
3-
NEW FEATURES
4-
5-
* Content-based detection of ASN.1/DER crypto containers at parse time. An
6-
opt-in Pkcs7Detector surfaces the subtype at detect() time,
7-
but must be enabled via configuration (TIKA-1997).
8-
9-
101
Release 4.0.0-beta-1 - 6/29/2026
112

123
BREAKING CHANGES

docs/modules/ROOT/examples/detector-pkcs7.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/modules/ROOT/pages/configuration/detectors.adoc

Lines changed: 0 additions & 57 deletions
This file was deleted.

docs/modules/ROOT/pages/configuration/index.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ JSON uses the backslash as an escape character, so path options (e.g. `tesseract
131131

132132
=== Other Configuration
133133

134-
* xref:configuration/detectors.adoc[Detectors] — Configuring content (MIME) detection, incl. the opt-in PKCS7/CMS detector
135134
* xref:configuration/digesters.adoc[Digesters] — Computing cryptographic hashes of documents
136135
* xref:configuration/encoding-detectors.adoc[Encoding Detectors] — Configuring charset/encoding detection
137136

tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -893,15 +893,6 @@
893893
<mime-type type="application/pkcs7-mime">
894894
<glob pattern="*.p7m"/>
895895
<glob pattern="*.p7c"/>
896-
<!-- CMS content types in the 1.2.840.113549.1.9.16.1.* arc (compressedData .9, authData .2,
897-
authEnvelopedData .23, ...) with the final OID byte masked. timestamped-data (.31) has the
898-
same shape but its own higher-priority magic below. The .7 arc (signed/enveloped/...) is
899-
matched by the pkcs7-signature block. Pkcs7Parser refines all of these to the smime-type. -->
900-
<magic priority="50">
901-
<match value="0x30" offset="0">
902-
<match value="0x060B2A864886F70D0109100100" mask="0xFFFFFFFFFFFFFFFFFFFFFFFF00" type="string" offset="2:6"/>
903-
</match>
904-
</magic>
905896
</mime-type>
906897

907898
<mime-type type="application/pkcs7-signature">
@@ -935,13 +926,8 @@
935926

936927
<mime-type type="application/timestamped-data">
937928
<glob pattern="*.tsd"/>
938-
<!-- CMS ContentInfo whose contentType is id-ct-timestampedData (1.2.840.113549.1.9.16.1.31),
939-
matching the full OID across the DER SEQUENCE length forms (short + 1..4-byte long).
940-
Higher priority than the masked pkcs7-mime .9.16.1.* magic so this exact OID wins. -->
941-
<magic priority="60">
942-
<match value="0x30" offset="0">
943-
<match value="0x060B2A864886F70D010910011F" type="string" offset="2:6"/>
944-
</match>
929+
<magic priority="50">
930+
<match value="0x3080060B2A864886F7" type="string" offset="0"/>
945931
</magic>
946932
</mime-type>
947933

@@ -4881,13 +4867,6 @@
48814867
<mime-type type="application/x-pkcs12">
48824868
<glob pattern="*.p12"/>
48834869
<glob pattern="*.pfx"/>
4884-
<!-- PFX ::= SEQUENCE { version INTEGER (v3), authSafe ContentInfo SEQUENCE, ... }: the
4885-
INTEGER 3 then a SEQUENCE (02 01 03 30) tells it apart from CMS (OID next) and keys. -->
4886-
<magic priority="50">
4887-
<match value="0x30" offset="0">
4888-
<match value="0x02010330" offset="2:6"/>
4889-
</match>
4890-
</magic>
48914870
</mime-type>
48924871
<mime-type type="application/x-pkcs7-certificates">
48934872
<glob pattern="*.p7b"/>

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/config/ConfigExamplesTest.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717
package org.apache.tika.config;
1818

19-
import static org.junit.jupiter.api.Assertions.assertEquals;
2019
import static org.junit.jupiter.api.Assertions.assertNotNull;
2120

2221
import java.io.InputStream;
@@ -28,10 +27,6 @@
2827
import org.junit.jupiter.api.io.TempDir;
2928

3029
import org.apache.tika.config.loader.TikaLoader;
31-
import org.apache.tika.detect.Detector;
32-
import org.apache.tika.io.TikaInputStream;
33-
import org.apache.tika.metadata.Metadata;
34-
import org.apache.tika.parser.ParseContext;
3530
import org.apache.tika.parser.Parser;
3631

3732
/**
@@ -99,29 +94,4 @@ public void testTesseractFullConfig() throws Exception {
9994
public void testFullMigrationExample() throws Exception {
10095
loadAndValidate("migration-full-example.json");
10196
}
102-
103-
/** The detectors.adoc example: enabling the opt-in pkcs-7-detector yields the CMS smime-type. */
104-
@Test
105-
public void testPkcs7DetectorConfig() throws Exception {
106-
Detector detector = loadDetectors("detector-pkcs7.json");
107-
assertEquals("application/pkcs7-mime; smime-type=signed-data",
108-
detect(detector, "testPKCS7_signed_data_def.p7m"));
109-
}
110-
111-
private Detector loadDetectors(String resourceName) throws Exception {
112-
try (InputStream is = getClass().getResourceAsStream(EXAMPLES_DIR + resourceName)) {
113-
assertNotNull(is, "Resource not found: " + resourceName);
114-
Path configFile = tempDir.resolve("tika-config.json");
115-
Files.writeString(configFile, new String(is.readAllBytes(), StandardCharsets.UTF_8),
116-
StandardCharsets.UTF_8);
117-
return TikaLoader.load(configFile).loadDetectors();
118-
}
119-
}
120-
121-
private String detect(Detector detector, String resource) throws Exception {
122-
try (TikaInputStream tis = TikaInputStream.get(
123-
getClass().getResourceAsStream("/test-documents/" + resource))) {
124-
return detector.detect(tis, new Metadata(), new ParseContext()).toString();
125-
}
126-
}
12797
}

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/mime/TestMimeTypes.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,9 +1242,10 @@ public void testCertificatesKeys() throws Exception {
12421242
// Parameters only have PEM form, always need data
12431243
assertTypeByData("application/x-x509-dsa-parameters", "testDSAPARAMS.pem");
12441244
assertTypeByData("application/x-x509-ec-parameters", "testECPARAMS.pem");
1245-
// PKCS12 is now identified by content via the PFX version-3 anchor (TIKA-1997/TIKA-3784)
1246-
assertType("application/x-pkcs12", "testRSAKEYandCERT.p12");
1247-
assertTypeByData("application/x-pkcs12", "testRSAKEYandCERT.p12");
1245+
// PKCS12 wrappers of Certs+Keys cannot currently be identified
1246+
// Once solved, see TIKA-3784, ought to work for name or data
1247+
//assertType("application/x-pkcs12", "testRSAKEYandCERT.p12");
1248+
//assertTypeByData("application/x-pkcs12", "testRSAKEYandCERT.p12"); // pass=tika
12481249
assertTypeByData("application/x-java-keystore", "KeyStore.jks");
12491250
}
12501251

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/java/org/apache/tika/parser/crypto/Pkcs7EndToEndTest.java

Lines changed: 0 additions & 65 deletions
This file was deleted.

tika-parsers/tika-parsers-standard/tika-parsers-standard-integration-tests/src/test/resources/config-examples/detector-pkcs7.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)