这是我的一个非常奇怪的问题:
我写了一个ws,用bouncycastle API检查签名邮件。当我在axis2环境之外测试该方法时,一切正常。一旦我在tomcat中部署了ws,一切都出错了。我有一个奇怪的异常,我已经本地化在bc api,在readObject()方法,当api试图将mime消息转换为asn1结构。下面是例外:
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);
...
我不认为问题来自于我写的代码,因为在axis2环境之外一切正常。我真的被困住了,我在任何地方都找不到这方面的信息。顺便说一下,MimeMessage构造函数在参数中接受System属性,为了确保这不是重点,我在两个环境(独立程序和axis2 ws)中都放置了完全相同的System属性。欢迎提出任何建议。谢谢大家。
好了,我找到问题了,真是奇怪……只要我从tomcat类路径中删除geronimo-javamail库,一切就顺利了……我真的不知道这个库有什么问题,但事实是tomcat没有它感觉更好。