-
Notifications
You must be signed in to change notification settings - Fork 37
Description
I don't know if this might be related to #1 (issue doesn't mention signed mails and it works with non signed mails) and #4 (based on the issue and the documentation it should work).
I've sent an S/MIME signed (not encrypted) mail with one attachment and one embedded image to two different mail adresses. One was saved as an msg file from Outlook and one as an eml file from the Gmail web interface. Then I've parsed them using this code block (slightly modified from the documentation) and printed the information about attachments and S/MIME details:
public static void main(String[] args) throws IOException {
String emlFileName = ".\\files\\testSigned2.eml";
String msgFileName = ".\\files\\testSigned2.msg";
try (FileInputStream fileInputStream = new FileInputStream(emlFileName)) {
Email email = EmailConverter.emlToEmail(fileInputStream);
printResult(email, emlFileName);
}
try (FileInputStream fileInputStream = new FileInputStream(msgFileName)) {
Email email = EmailConverter.outlookMsgToEmail(fileInputStream);
printResult(email, msgFileName);
}
}
private static void printResult(Email email, String fileName) {
System.out.println("-----" + fileName + "-----");
System.out.println("---Attachments---");
for(AttachmentResource attachmentResource: email.getAttachments()) {
System.out.println(attachmentResource.getName());
}
System.out.println("---Decrypted Attachments---");
for(AttachmentResource attachmentResource: email.getDecryptedAttachments()) {
System.out.println(attachmentResource.getName());
}
System.out.println("---Embedded Images---");
for(AttachmentResource attachmentResource: email.getEmbeddedImages()) {
System.out.println(attachmentResource.getName());
}
System.out.println("---S/MIME Details---");
OriginalSmimeDetails details = email.getOriginalSmimeDetails();
System.out.println("Mode: " + details.getSmimeMode()); // SIGNED
System.out.println("Mime: " + details.getSmimeMime()); // application/pkcs7-mime or multipart/signed
System.out.println("Type: " + details.getSmimeType()); // signed-data, enveloped-data
System.out.println("Name: " + details.getSmimeName()); // smime.p7m or smime.p7s
System.out.println("Micalg: " + details.getSmimeMicalg()); // ie. sha-512
System.out.println("SignedBy: " + details.getSmimeSignedBy()); // email or name used
System.out.println("");
}
}The results I get show that the msg file is missing the attached image, the embedded image and basically all S/MIME information:
-----.\files\testSigned2.eml-----
---Attachments---
gettyimages-1254246621-1.jpg
smime.p7s
---Decrypted Attachments---
gettyimages-1254246621-1.jpg
smime.p7s
---Embedded Images---
[email protected]
---S/MIME Details---
Mode: SIGNED
Mime: multipart/signed
Type: null
Name: null
Micalg: SHA1
SignedBy: [email protected]
-----.\files\testSigned2.msg-----
---Attachments---
smime.p7m
---Decrypted Attachments---
smime.p7m
---Embedded Images---
---S/MIME Details---
Mode: PLAIN
Mime: null
Type: null
Name: null
Micalg: null
SignedBy: null
What I've noticed is when I extract the p7m file from the msg both images are Base64 encoded inside the file together with most of the S/MIME Details (couldn't verify SignedBy, but multipart/signed and SHA1 are there). Also looking at the p7m file, the first lines are:
MIME-Version: 1.0
Content-Type: multipart/signed;
protocol="application/x-pkcs7-signature";
micalg=SHA1;
boundary="----=_NextPart_000_003F_01D70933.15C7D9C0"
Seeing that protocol is present I would have expected to not run into this issue (bbottema/simple-java-mail#292) when using 6.4.5 instead of 6.5.0 but the NullPointerException is still there, so there might be some problem reading the information.
I've attached both used mails:
signedMails.zip