public RemCryptoManager(string certName, StoreName certStoreName)
    {
        CertificateName = certName;
        CertStoreName   = certStoreName;

        X509Store store = new X509Store(CertStoreName, StoreLocation.LocalMachine);

        store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
        X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, false);

        certificates = certificates.Find(X509FindType.FindBySubjectDistinguishedName, "CN=" + CertificateName, false);

        if (certificates.Count != 0)
        {
            Certificate = certificates[0];
            if (!Certificate.HasPrivateKey && certStoreName.Equals(StoreName.My))
            {
                store.Close();
                throw new Exception("Sertifikanın private key i bulunamadı");
            }
        }
        else
        {
            store.Close();
            throw new Exception("Sertifika bulunamadı");
        }

        store.Close();
    }