5
SignedCMS를 사용하여 서명하고있는 파일에 서명 시간 속성을 추가하려고합니다. 인코딩에 던져PKCS7 서명 된 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;
}
오류 :
CryptographicException: The object identifier is poorly formatted.
제대로 서명 시간을 추가하는 방법에 어떤 아이디어? 내가 서명 시간을 ASN.1로 인코딩 된 객체로 변환하고 cryptoAtty
의 값에 추가해야한다고 생각합니다. 어떻게 날짜/시간을 ASN.1 인코딩 된 객체로 변환합니까?