NullPointerException in SmimeUtilFixed when protocol is missing (which is valid)
Faelean opened this issue · comments
When using the outlookMsgToEmailBuilder
function
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
:
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
outlookMsgToEmailBuilder
with 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
.
If you want I can now provide an example mail that causes the error, I'd have to send it to you via mail though.
The mail crashes the program I used in #303.
Exception in thread "main" org.simplejavamail.internal.smimesupport.SmimeException: Error unwrapping S/MIME enveloped attachment:
AttachmentResource{
name='smime.p7m',
dataSource.name=smime.p7m,
dataSource.getContentType=multipart/signed
}
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:232)
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:188)
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:121)
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:91)
at org.simplejavamail.converter.EmailConverter.decryptAttachments(EmailConverter.java:233)
at org.simplejavamail.converter.EmailConverter.outlookMsgToEmailBuilder(EmailConverter.java:227)
at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:209)
at org.simplejavamail.converter.EmailConverter.outlookMsgToEmail(EmailConverter.java:201)
at ReadMail.main(ReadMail.java:29)
Caused by: net.markenwerk.utils.mail.smime.SmimeException
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.handledException(SmimeUtilFixed.java:83)
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.getStatus(SmimeUtilFixed.java:40)
at org.simplejavamail.internal.smimesupport.SMIMESupport.determineStatus(SMIMESupport.java:333)
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAndUnsignAttachment(SMIMESupport.java:260)
at org.simplejavamail.internal.smimesupport.SMIMESupport.decryptAttachments(SMIMESupport.java:230)
... 8 more
Caused by: java.lang.NullPointerException
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.isSmimeSignatureProtocoll(SmimeUtilFixed.java:75)
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.isSmimeSignatureContentType(SmimeUtilFixed.java:71)
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.getStatus(SmimeUtilFixed.java:45)
at org.simplejavamail.internal.smimesupport.SmimeUtilFixed.getStatus(SmimeUtilFixed.java:38)
... 11 more
Yes please, that would be most helpful 👍
Released in 6.5.0