Skip to content

Added missing support for S/MIME envloped signing #252

@cgruber0

Description

@cgruber0

Hi,

I have troubles getting the content of an email that is encrypted and signed (see attachment). The email itself only contains one smime.p7m attachment.

I use following code:

FileInputStream f = new FileInputStream(new File("email.eml"));

FileInputStream key = new FileInputStream(new File("keystore.p12"));
FileInputStream key2 = new FileInputStream(new File("keystore.p12"));

SmimeKeyStore smimeKeyStore = new SmimeKeyStore(key, "pw".toCharArray());
String alias = smimeKeyStore.getPrivateKeyAliases().iterator().next();

Pkcs12Config yourPkcs12Config = Pkcs12Config.builder()
        .pkcs12Store(key2) // path, File or InputStream
        .storePassword("pw")
        .keyAlias(alias)
        .keyPassword("pw")
        .build();

Email mergedEmail = EmailConverter.emlToEmail(f, yourPkcs12Config);
List<AttachmentResource> list = mergedEmail.getDecryptedAttachments();

for (AttachmentResource r : list) {
    play.Logger.info(r.readAllData());
}

But the output of r.readAllData() gives me binary data only.

When I open the email in Thunderbird it is decrypted correctly, it contains text only.

Can you please help me to get the actual content?
email.txt

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions