X509Certificate2 certificate = new X509Certificate2 "c:\....p12", "PASSWORD");
byte[] dataToSign = Encoding.UTF8.GetBytes("text");
ContentInfo contentInfo = new ContentInfo(dataToSign);
SignedCms signedCms = new SignedCms(contentInfo);
// SignedCms signedCms = new SignedCms(contentInfo, true); - тоже не подходит.
CmsSigner cmsSigner = new CmsSigner(certificate);
cmsSigner.DigestAlgorithm = new Oid("1.3.14.3.2.26");//sha1
signedCms.ComputeSignature(cmsSigner);
byte[] myCmsMessage = signedCms.Encode();
Convert.ToBase64String(myCmsMessage);