我有以下java代码(BouncyCastle 1.48):
CMSSignedDataStreamGenerator generator = new CMSSignedDataStreamGenerator();
generator.addSignerInfoGenerator(signerInfoGenerator);
generator.addCertificates(certStore);
FileOutputStream fos = new FileOutputStream("D:\\Data\\Desktop\\Test\\singedData.txt");
OutputStream theSignedDataStream = generator.open(fos, true);
IOUtils.copy(new FileInputStream("D:\\Data\\Desktop\\Test\\unsignedData.txt"), theSignedDataStream);
现在:数据已签名并写入signedData.txt 文件。问题是某些字符写错了(数据是具有 base64 编码内容的 mime 容器)。以下是数据片段:
ICAgIDxOQU1FLUFERFJFU1M+CiAgICAgICAgICA8TkFNRT4KICAgICAgICAgICAg
PExpbmUtMzU+TXVzdGVya3VuZGUgUGV0ZXIgSHV???,???èiZXI8L0xpbmUtMzU+CiAgICAg
ICAgICA8L05BTUU+CiAgICAgICAgICA8U1RSRUVUPgogICAgICAgICAgICA8TGlu
哪里的???,???代表[EOT],[ETX]('传输结束'和'文本结束'的ascii控制字符。在原始源数据中,没有出现错误字符的地方:...SHV???, ???éiZX...原来是...SHViZHX...
第二个片段:
Content-Transfer-Encoding: base64
Content-Type: application/pdf
Content-[EOT]‚[ETX]Description: The PDF Title
有人可以帮我吗?我究竟做错了什么?
最好的问候,弗洛里安