SignWithCertificate() public static method

public static SignWithCertificate ( string message, X509Certificate2 x509Certificate ) : byte[]
message string
x509Certificate System.Security.Cryptography.X509Certificates.X509Certificate2
return byte[]
        /// <summary>
        /// Signs a message using the private key in the certificate
        /// </summary>
        /// <param name="message">Message that needs to be signed</param>
        /// <returns>Signed message as a byte array</returns>
        public byte[] Sign(string message)
        {
            CryptographyHelper helper = new CryptographyHelper();

            return(helper.SignWithCertificate(message, this.Certificate));
        }
        public void SignWithCertificateTest()
        {
            const string Message = "This is a test message";
            string[] certs = { "valid_cert.pfx", "valid_cert2.pfx" };
            for (int i = 0; i < 2; i++)
            {
                X509Certificate2 x509Certificate = new X509Certificate2(certs[i], "password", X509KeyStorageFlags.Exportable);
                byte[] rawData = x509Certificate.Export(X509ContentType.Pkcs12, "password");

                ICryptographyHelper cryptoHelper = new CryptographyHelper();
                byte[] signature = cryptoHelper.SignWithCertificate(Message, rawData, "password");
                Verify.IsNotNull(signature);

                GC.Collect();
                GC.WaitForPendingFinalizers();

                signature = cryptoHelper.SignWithCertificate(Message, rawData, "password");
                Verify.IsNotNull(signature);
            }
        }
 internal byte[] Sign(string message)
 {
     return(CryptographyHelper.SignWithCertificate(message, this.Certificate));
 }