public bool isActiveLicense(string license)
{
bool response = false;
try
{
System.Security.Cryptography.X509Certificates.X509Certificate certtmp = new System.Security.Cryptography.X509Certificates.X509Certificate(license);
System.DateTime a = new System.DateTime(1, 1, 1, 0, 0, 0);
System.DateTime fromDate = System.Convert.ToDateTime(certtmp.GetEffectiveDateString());
if (fromDate == a)
{
System.Threading.Thread.Sleep(1000);
fromDate = System.Convert.ToDateTime(certtmp.GetEffectiveDateString());
}
System.DateTime toDate = System.Convert.ToDateTime(certtmp.GetExpirationDateString());
if (toDate == a)
{
System.Threading.Thread.Sleep(1000);
toDate = System.Convert.ToDateTime(certtmp.GetEffectiveDateString());
}
int result = System.DateTime.Compare(fromDate, System.DateTime.Now);
int result2 = System.DateTime.Compare(System.DateTime.Now, toDate);
if (result <= 0 && result2 <= 0)
{
response = true;
}
}
catch (System.Security.Cryptography.CryptographicException)
{
}
return(response);
}