5
SignedCMS kullanarak imza attığım bir dosyaya imzalama süresi özniteliğini eklemeye çalışıyorum. Encode atılanPKCS7 İmzalı CMS'ye İmzalama Zamanı Ekleme?
private byte[] signFile(byte[] fileContent, X509Certificate2 verificationCert)
{
ContentInfo contentInfo = new ContentInfo(fileContent);
SignedCms signedCMS = new SignedCms(contentInfo);
CmsSigner cmsSigner = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, verificationCert);
Oid signedDate = new Oid("1.2.840.113549.1.9.5"); //oid for PKCS #9 signing time
signedDate.Value = DateTime.Now.ToString();
CryptographicAttributeObject cryptoAtty = new CryptographicAttributeObject(signedDate);
cmsSigner.SignedAttributes.Add(cryptoAtty);
signedCMS.ComputeSignature(cmsSigner, false);
byte[] encoded = signedCMS.Encode();
return encoded;
}
Hata:
CryptographicException: The object identifier is poorly formatted.
düzgün imzalama süresi ekleme hakkında herhangi bir fikir? İmzalama süresini ASN.1 kodlu bir nesneye dönüştürmek ve bunu cryptoAtty
'un değerlerine eklemek zorunda kalabilirim. Bir tarih/saat ASN.1 Kodlanmış bir nesneye nasıl dönüştürülür? kolay oldu