1

我想创建 S/mime。我使用 bouncyCastle 生成 mime 消息,我必须签署这个 mime 消息。我必须计算 mime 消息的哈希并使用另一个应用程序对其进行签名。我做到了,但 Outlook 说“可以更改此消息的内容”。如何计算哈希 mime 消息的正文?可能我必须删除一些标题信息或添加?任何人都可以帮助我吗?

    MimeBodyPart bodyPart = new MimeBodyPart();
                Date gonderimZamani = new Date();
                bodyPart.setContent(dataMultiPart); bodyPart.addHeader("To", kime);

                bodyPart.addHeader("Date", "2014-12-10 14:00");
                bodyPart.addHeader("From", kimden);
bodyPart.addHeader("To", kime);
                bodyPart.addHeader("MIME-Version", "1.0");
                bodyPart.addHeader("Message-ID", mimeMessage.getMessageID());
                bodyPart.addHeader("Subject", mimeMessage.getSubject());
    fileOutputStream = new FileOutputStream("D:/imzasiz.eml");
            bodyPart.writeTo(fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
    hashAndMessageId.setHash(hashFile(new File("D:/imzasiz.eml"), ozetAlg));

这是用于计算哈希的 eml 文件

Date: 2014-12-10 14:00
From: ibrahimkiraz@xx.com
To: ozgurkilic@hotmail.com
Message-ID: <1610043979.41418204127486.JavaMail.ibrahim.kiraz@kepikiraz>
Subject: konu
MIME-Version: 1.0
Content-Type: multipart/mixed; 
    boundary="----=_Part_2_1609223453.1418204127482"

------=_Part_2_1609223453.1418204127482
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

Deneme mail
------=_Part_2_1609223453.1418204127482
Content-Type: application/octet-stream; name=2009.pdf
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=2009.pdf

JVBERi0xLjMKJZKgoooKNCAwIG9iago8PC9UeXBlL1hPYmplY3QKL1N1YnR5cGUvSW1hZ2UKL1dp
ZHRoIDE2NjQKL0hlaWdodCAyMzM5Ci9CaXRzUGVyQ29tcG9uZW50IDEKL0NvbG9yU3BhY2UvRGV2
aWNlR3JheQovRmlsdGVyWy9DQ0lUVEZheERlY29kZV0KL0RlY29kZVBhcm1zWzw8L0NvbHVtbnMg
.....
4

0 回答 0