本文整理匯總了C#中Org.BouncyCastle.X509.X509Certificate.IsValid方法的典型用法代碼示例。如果您正苦於以下問題:C# X509Certificate.IsValid方法的具體用法?C# X509Certificate.IsValid怎麽用?C# X509Certificate.IsValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Org.BouncyCastle.X509.X509Certificate
的用法示例。
在下文中一共展示了X509Certificate.IsValid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VerifyCertificate
/**
* Loads the default root certificates at <java.home>/lib/security/cacerts
* with the default provider.
* @return a <CODE>KeyStore</CODE>
*/
// public static KeyStore LoadCacertsKeyStore() {
// return LoadCacertsKeyStore(null);
// }
/**
* Loads the default root certificates at <java.home>/lib/security/cacerts.
* @param provider the provider or <code>null</code> for the default provider
* @return a <CODE>KeyStore</CODE>
*/
// public static KeyStore LoadCacertsKeyStore(String provider) {
// File file = new File(System.GetProperty("java.home"), "lib");
// file = new File(file, "security");
// file = new File(file, "cacerts");
// FileInputStream fin = null;
// try {
// fin = new FileInputStream(file);
// KeyStore k;
// if (provider == null)
// k = KeyStore.GetInstance("JKS");
// else
// k = KeyStore.GetInstance("JKS", provider);
// k.Load(fin, null);
// return k;
// }
// catch (Exception e) {
// throw new ExceptionConverter(e);
// }
// finally {
// try{fin.Close();}catch(Exception ex){}
// }
// }
/**
* Verifies a single certificate.
* @param cert the certificate to verify
* @param crls the certificate revocation list or <CODE>null</CODE>
* @param calendar the date or <CODE>null</CODE> for the current date
* @return a <CODE>String</CODE> with the error description or <CODE>null</CODE>
* if no error
*/
public static String VerifyCertificate(X509Certificate cert, object[] crls, DateTime calendar) {
try {
if (!cert.IsValid(calendar))
return "The certificate has expired or is not yet valid";
}
catch (Exception e) {
return e.ToString();
}
return null;
}