我想创建S / mime。我使用bouncyCastle生成mime消息,我必须签署此mime消息。我必须计算mime消息的哈希并使用另一个应用程序对其进行签名。我做了,但是前景说“这条消息的内容可以改变。”我怎样才能计算哈希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
.....