仅在axis2 webservice环境中使用bouncycastle API验证已签名邮件的问题

时间:2011-09-16 09:35:57

标签: email axis2 bouncycastle signed

这是我非常奇怪的问题:

我写了一个用bouncycastle API检查签名邮件的ws。当我在axis2环境外测试方法时,一切正常。一旦我在tomcat中部署了ws,一切都出错了。我有一个奇怪的例外,当api尝试将mime消息转换为asn1结构时,我在readObject()方法中将其本地化在bc api中。 这是例外:

Caused by: org.bouncycastle.cms.CMSException: IOException reading content.
    at org.bouncycastle.cms.CMSUtils.readContentInfo(Unknown Source)
    at org.bouncycastle.cms.CMSUtils.readContentInfo(Unknown Source)
    at org.bouncycastle.cms.CMSSignedData.<init>(Unknown Source)
    at org.bouncycastle.mail.smime.SMIMESigned.<init>(Unknown Source)
... 32 more
Caused by: java.io.EOFException: EOF found when length expected
    at org.bouncycastle.asn1.ASN1InputStream.readLength(Unknown Source)
    at org.bouncycastle.asn1.ASN1InputStream.readLength(Unknown Source)
    at org.bouncycastle.asn1.ASN1InputStream.readObject(Unknown Source

当我调用SignedMailValidator构造函数时会引发异常。

private static SignBean verifySignedMail(MimeMessage msg, PKIXParameters param, Log log)
            throws SarvaraException
   {
      String errorSubject = "";
      String errorDetails = "";
      SignBean signReturn = new SignBean();
      // set locale for the output
      Locale loc = Locale.FRENCH;
      // Locale loc = Locale.GERMAN;
      // validate signatures
      SignedMailValidator validator;
      try
      {
         validator = new SignedMailValidator(msg, param);
         ...

我不认为问题来自我写的代码,因为一切都好oustide axis2环境。我真的被卡住了,我在任何地方都找不到任何东西。顺便说一句,MimeMessage构造函数在参数中获取Sytem属性并确保不是重点,我在两个环境(独立prog和axis2 ws)中都放置了完全相同的System属性。我们欢迎任何建议。谢谢大家。

1 个答案:

答案 0 :(得分:0)

好的,我发现了问题,这真的很奇怪......一旦我从tomcat类路径中删除geronimo-javamail librarie,一切顺利......我真的不知道这个问题是什么但是如果没有它,tomcat会感觉更好。