3
파일 서명 방법에 대한 유용한 자습서가 있습니까? bouncycastle을 사용하여 asn1 pkcs7 패키지로 묶으십시오.asn1 signedmessage 서명 및 생성 - Bouncycastle
파일 서명 방법에 대한 유용한 자습서가 있습니까? bouncycastle을 사용하여 asn1 pkcs7 패키지로 묶으십시오.asn1 signedmessage 서명 및 생성 - Bouncycastle
언젠가 내가 bouncyCastle 앱 내부의 예에서 그 방법을 발견했습니다.
실제로는 IText에서 찾은 것보다 훨씬 간단하고 직선적 인 방법입니다 (프레임 워크 자체의 정교함을 제거하지 않음).
코드는 뭔가 같은 :
AsymmetricCipherKeyPair signaturePair;
X509Certificate signatureCert;
IList certList = new ArrayList();
IList crlList = new ArrayList();
CmsProcessable msg = new CmsProcessableByteArray(Encoding.ASCII.GetBytes("I hate hello world!"));
certList.Add(signatureCert);
certList.Add(OrigCert);
crlList.Add(SignCrl);
IX509Store x509Certs = X509StoreFactory.Create(
"Certificate/Collection",
new X509CollectionStoreParameters(certList));
IX509Store x509Crls = X509StoreFactory.Create(
"CRL/Collection",
new X509CollectionStoreParameters(crlList));
CmsSignedDataGenerator gen = new CmsSignedDataGenerator();
gen.AddSigner(signaturePair.Private, signatureCert, CmsSignedDataGenerator.DigestSha1);
gen.AddCertificates(x509Certs);
gen.AddCrls(x509Crls);
CmsSignedData signedData = gen.Generate(msg, true);
//saving in BER encoding
Stream stream = new MemoryStream(signedData.GetEncoded());