【求助】golang 生成待签名的问题

之前在 java 用 bouncycastle 库对数据进行 SHA1withRSA 签名后,生成带签名的数字信封。 现在要用 go 重写这段代码,但是谷歌好久也找不到该如何实现,求助该如何实现。

java 代码如下:


CertDTO certDto = CertUtil.getCertInfo(password, cert);
X509Certificate cerx509 = certDto.getCert()[0];
List<X509Certificate> certList = new ArrayList();
CMSTypedData msg = new CMSProcessableByteArray(data);
certList.add(cerx509);
Store certs = new JcaCertStore(certList);
CMSSignedDataGenerator gen = new CMSSignedDataGenerator();
ContentSigner sha1Signer = 
    (new JcaContentSignerBuilder("SHA1withRSA"))
    .setProvider("BC").build(certDto.getPriKey());
gen.addSignerInfoGenerator(
    (new JcaSignerInfoGeneratorBuilder((
    new JcaDigestCalculatorProviderBuilder())
    .setProvider("BC").build())).build(sha1Signer, cerx509));
gen.addCertificates(certs);
CMSSignedData sigData = gen.generate(msg, isDetach);
signedData = sigData.getEncoded();
            

共 0 个回复