本文整理汇总了C#中X509Certificate2.Verify方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.Verify方法的具体用法?C# X509Certificate2.Verify怎么用?C# X509Certificate2.Verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.Verify方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestVerify
public static void TestVerify()
{
using (var microsoftDotCom = new X509Certificate2(TestData.MicrosoftDotComSslCertBytes))
{
// Fails because expired (NotAfter = 10/16/2016)
Assert.False(microsoftDotCom.Verify());
}
using (var microsoftDotComIssuer = new X509Certificate2(TestData.MicrosoftDotComIssuerBytes))
{
Assert.True(microsoftDotComIssuer.Verify()); // NotAfter=10/31/2023
}
using (var microsoftDotComRoot = new X509Certificate2(TestData.MicrosoftDotComRootBytes))
{
Assert.True(microsoftDotComRoot.Verify()); // NotAfter=7/17/2036
}
}
示例2: TestVerify
public void TestVerify()
{
bool success;
using (var microsoftDotCom = new X509Certificate2(TestData.MicrosoftDotComSslCertBytes))
{
// Fails because expired (NotAfter = 10/16/2016)
Assert.False(microsoftDotCom.Verify(), "MicrosoftDotComSslCertBytes");
}
using (var microsoftDotComIssuer = new X509Certificate2(TestData.MicrosoftDotComIssuerBytes))
{
// NotAfter=10/31/2023
success = microsoftDotComIssuer.Verify();
if (!success)
{
LogVerifyErrors(microsoftDotComIssuer, "MicrosoftDotComIssuerBytes");
}
Assert.True(success, "MicrosoftDotComIssuerBytes");
}
using (var microsoftDotComRoot = new X509Certificate2(TestData.MicrosoftDotComRootBytes))
{
// NotAfter=7/17/2036
success = microsoftDotComRoot.Verify();
if (!success)
{
LogVerifyErrors(microsoftDotComRoot, "MicrosoftDotComRootBytes");
}
Assert.True(success, "MicrosoftDotComRootBytes");
}
}
示例3: CreateInstances
void CreateInstances()
{
bool res = false ;
string cd = Environment.CurrentDirectory + "\\" ;
X509Certificate2 real = null , fuzzed = null ;
string test = String.Empty ;
Result r = (Result) 0;
string[] realFiles = GetFiles( cd , allCerts ) ;
for( int i = 0 ; i < realFiles.Length ; i++ )
{
string fileName = realFiles[i].ToUpper().Replace( cd.ToUpper() , String.Empty ) ;
string[] fuzzFiles = GetFiles( dir , fileName.Substring( 0 , fileName.IndexOf(".") ) + "-*.c*r*" ) ;
try
{
real = new X509Certificate2( realFiles[i] ) ;
}
catch(Exception)
{
Console.WriteLine( realFiles[i] ) ;
break ;
}
Console.WriteLine( "Going to test {0}" , realFiles[i] ) ;
for( int j = 0 ; j < fuzzFiles.Length ; j++ )
{
res= false ;
if( fuzzFiles[j].ToLower().IndexOf(".tmp" ) > 0 )
{
j++ ;
if( j == fuzzFiles.Length )
break ;
}
Console.WriteLine( " with {0}" , fuzzFiles[j] ) ;
try
{
fuzzed = new X509Certificate2( fuzzFiles[j] ) ;
fuzzed.Verify() ;
res = fuzzed.ToString(true).Equals(real.ToString(true)) ;
r = res ? Result.Equals : Result.NotEquals ;
test = fuzzFiles[i] + " \n" ;
test += String.Format( "{0}\n\n!=\n\n{1}" , fuzzed.ToString(true),real.ToString(true) ) ;
}
catch(CryptographicException)
{
res = true ;
r = Result.CryptographicException ;
}
catch(Exception e)
{
Console.WriteLine(e) ;
r = Result.Exception ;
}
finally
{
Console.WriteLine( r ) ;
Eval( r!=Result.Exception , test ) ;
}
}
}
}