Tag: bouncycastle asn.1

C#SignedCms的Java实现

我正在使用Java实现C#SignedCmsfunction。 我正在使用bouncycastle libs。 问题是我获得的java签名与使用SignedCms生成的签名不同。 C#代码 X509Certificate2 certificate = new X509Certificate2(“myCertPath”, “myPass”); String text = “text”; ContentInfo contentInfo = new ContentInfo(System.Text.Encoding.UTF8.GetBytes(text)); SignedCms cms = new SignedCms(contentInfo, false); CmsSigner signer = new CmsSigner(certificate); signer.IncludeOption = X509IncludeOption.None; signer.DigestAlgorithm = new Oid(“SHA1”); cms.ComputeSignature(signer, false); byte[] signature = cms.Encode(); print(signature); Java代码 Security.addProvider(new BouncyCastleProvider()); char[] password = “myPass”.toCharArray(); String text = […]