5
Sto tentando di aggiungere l'attributo del tempo di firma a un file che sto firmando utilizzando SignedCMS.Aggiungi tempo di firma a PKCS7 Firmato CMS?
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;
}
errore gettato su Encode:
CryptographicException: The object identifier is poorly formatted.
Tutte le idee su come aggiungere correttamente il tempo di firma? Penso che potrebbe essere necessario convertire il tempo di firma in un oggetto codificato ASN.1 e aggiungerlo ai valori di cryptoAtty
. Come si converte la data/ora in un oggetto codificato ASN.1?