当前位置: 首页>>代码示例>>C#>>正文


C# X509Certificate2.Verify方法代码示例

本文整理汇总了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
            }
        }
开发者ID:dotnet,项目名称:corefx,代码行数:18,代码来源:CertTests.cs

示例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");
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:32,代码来源:CertTests.cs

示例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 ) ; 
					}
				}
			}
		}
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:60,代码来源:X509FuzzTest.cs


注:本文中的X509Certificate2.Verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。