public static string SignData(byte[] bytes, X509Certificate2 certificate)
{
var contentInfo = new ContentInfo(bytes);
var signedCms = new SignedCms(contentInfo, true);
var cmsSigner = new CmsSigner(certificate);
signedCms.ComputeSignature(cmsSigner);
var signature = signedCms.Encode();
return Convert.ToBase64String(signature);
}