我使用EnvelopedSignature类实现消息的加密。
ByteArrayOutputStream envelopedByteArrayOutStream = new ByteArrayOutputStream ();
EnvelopedSignature signature = new EnvelopedSignature ();
if (cert != null) {
signature.addKeyAgreeRecipient ((X509Certificate) cert);
// or signature.addKeyTransRecipient ((X509Certificate) cert);
} else {
throw new Exception ("Certificate error.");
}
signature.open (envelopedByteArrayOutStream);
signature.update (inData, 0, inData.length);
signature.close ();
我在系统中收到错误“输出密码初始化失败”
signature.open (envelopedByteArrayOutStream);
帮助了解错误。
P.S。权利变更对我没有帮助(https://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html)
谢谢。