You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Justin Robinson <dk...@fluidnotions.com> on 2013/09/25 08:31:38 UTC

apache-jdkim-0.2 2 is DKIM signing for multipart/* supposed to work?

Hi,
I'm integrating an application (which uses Sendmail as MTA, and hybrid
java/python mailing list manager) with apache jdkim.

Other existing oss libraries (which I'd previously based the app on) seem
to work fine for plain text, but multipart/alternative results in DKIM
result: fail (wrong body hash)

I see there are no junit tests for content type multipart DKIM only for
it's predecessor DK.

In org.apache.james.jdkim.impl.Message on line 79

((SingleBody) message.getBody()).getInputStream();

However RFC 4871, say that no special processing is required for multipart,
so this cast might be valid.

I'm debugging and would like to affirm the premiss that pache-jdkim-0.2 for
multipart/* content types is indeed considered functional?
when run on a multipart produces the exception (I added a try/catch -
throwable):

java.lang.ClassCastException: org.apache.james.mime4j.message.MultipartImpl
cannot be cast to org.apache.james.mime4j.dom.SingleBody
at org.apache.james.jdkim.impl.Message.getBodyInputStream(Message.java:80)
at org.apache.james.jdkim.DKIMSigner.sign(DKIMSigner.java:85)

I spoke to someone on the mailing list he seems to believe it does work,
hash a bug been fixed in a post-release build, or has this uncaught
exception been slipping through the net?

Thanks.

- Justin

Re: apache-jdkim-0.2 2 is DKIM signing for multipart/* supposed to work?

Posted by Stefano Bagnara <ap...@bago.org>.
2013/9/25 Justin Robinson <dk...@fluidnotions.com>:
> [...]
> java.lang.ClassCastException: org.apache.james.mime4j.message.MultipartImpl
> cannot be cast to org.apache.james.mime4j.dom.SingleBody
> at org.apache.james.jdkim.impl.Message.getBodyInputStream(Message.java:80)
> at org.apache.james.jdkim.DKIMSigner.sign(DKIMSigner.java:85)

This may happen if mime4j is not correctly instantiated/invoked.
mime4j has to be instructed to do raw parsing (instead of the default
multipart parsing).

BTW I use DKIMSign mailet to sign millions messages. DKIMSign doesn't
use mime4j.
Maybe there is a bug in the mime4j parsing part.

Are you using mime4j-0.7 ?

http://svn.apache.org/viewvc/james/jdkim/tags/apache-jdkim-project-0.2/main/src/main/java/org/apache/james/jdkim/impl/Message.java?view=markup
MessageServiceFactory mbf = MessageServiceFactory.newInstance();
70 mbf.setAttribute("MimeEntityConfig", mec);
71 mbf.setAttribute("FlatMode", true);
72 mbf.setAttribute("ContentDecoding", false);

The FlatMode and ContentDecoding options are needed in order for mime4j to work.
If they are not used or mime4j doesn't get it then you get a
MultipartImpl object and jdkim doesn't work.

Stefano

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org