-
-
Notifications
You must be signed in to change notification settings - Fork 275
Description
When using the outlookMsgToEmailBuilder function
Line 201 in cd197aa
| public static EmailFromOutlookMessage outlookMsgToEmailBuilder(@NotNull final InputStream msgInputStream) { |
I sometimes get this error message:
org.simplejavamail.internal.smimesupport.SmimeException: Error unwrapping S/MIME enveloped attachment:
AttachmentResource{
name='smime.p7s',
dataSource.name=smime.p7s,
dataSource.getContentType=multipart/signed
}
This is caused by a Nullpointer in this function when the contentType in the calling function does not contain the parameter protocol:
Lines 59 to 62 in cd197aa
| private static boolean isSmimeSignatureProtocoll(String protocol) { | |
| return protocol.equalsIgnoreCase("application/pkcs7-signature") | |
| || protocol.equalsIgnoreCase("application/x-pkcs7-signature"); | |
| } |
Lines 53 to 57 in cd197aa
| private static boolean isSmimeSignatureContentType(ContentType contentType) { | |
| String baseContentType = contentType.getBaseType(); | |
| return baseContentType.equalsIgnoreCase("multipart/signed") | |
| && isSmimeSignatureProtocoll(contentType.getParameter("protocol")); | |
| } |
I haven't been able to create an email with this problem myself (if necessary I can obtain one) but here is the way we handle these emails:
- Drag & Drop from Outlook to a Browser
- Transfer the file to a server
- Convert the file to a ByteArrayInputStream
- Call
outlookMsgToEmailBuilderwith that InputStream
I don't know why these mails don't contain a protocol, but the easiest way to prevent the NullPointer would be to make the isSmimeSignatureProtocoll function nullsave by using protocol as input parameter for equalsIgnoreCase:
"application/pkcs7-signature".equalsIgnoreCase(protocol) || "application/x-pkcs7-signature".equalsIgnoreCase(protocol)
This would change the NullPointer to a false.