Код: Выделить всё
SignTool.exe sign /v /n "certCN" /p7 . /p7co "OID" /fd certHash
< /code>
Это моя попытка в .net < /p>
private static void SignFileBlob(string filePath,
X509Certificate2 signingCertificate,
string? contentOid = null)
{
byte[] fileContent = File.ReadAllBytes(filePath);
string contentTypeOid = contentOid ?? "1.2.840.113549.1.7.1";
ContentInfo contentInfo = new(new Oid(contentTypeOid), fileContent);
SignedCms signedCms = new(contentInfo, false);
CmsSigner signer = new(signingCertificate);
string hashOid = GetHashOidFromCertSignatureAlgorithm(signingCertificate);
signer.DigestAlgorithm = new Oid(hashOid);
signer.IncludeOption = X509IncludeOption.EndCertOnly;
signedCms.ComputeSignature(signer, false);
byte[] signedBytes = signedCms.Encode();
File.Delete(filePath);
File.WriteAllBytes(filePath, signedBytes);
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... oid-in-c-c
Мобильная версия