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


C# X509Certificate.GetRawCertData方法代码示例

本文整理汇总了C#中X509Certificate.GetRawCertData方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate.GetRawCertData方法的具体用法?C# X509Certificate.GetRawCertData怎么用?C# X509Certificate.GetRawCertData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在X509Certificate的用法示例。


在下文中一共展示了X509Certificate.GetRawCertData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateCertAgainstBaseline


//.........这里部分代码省略.........
        }

        TestFramework.LogInformation("  Validating field: Format");
        if (!certVals["Format"].Equals(cer.GetFormat()))
        {
            TestFramework.LogError("004", "Expected format: " + certVals["Format"] + ", found: " + cer.GetFormat());
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: Issuer");
        if (!certVals["Issuer"].Equals(cer.Issuer))
        {
            TestFramework.LogError("005", "Expected issuer: " + certVals["Issuer"] + ", found: " + cer.Issuer);
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: KeyAlgorithm");
        if (!certVals["KeyAlgorithm"].Equals(cer.GetKeyAlgorithm()))
        {
            TestFramework.LogError("006", "Expected key algorithm: " + certVals["KeyAlgorithm"] + ", found: " + cer.GetKeyAlgorithm());
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: KeyAlgorithmParameters");
        if (!certVals["KeyAlgorithmParameters"].Equals(cer.GetKeyAlgorithmParametersString()))
        {
            TestFramework.LogError("007", "Expected key alg parameters :" + certVals["KeyAlgorithmParameters"] + ", found :" +
                    cer.GetKeyAlgorithmParametersString());
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: PublicKeyString");
        if (!certVals["PublicKeyString"].Equals(cer.GetPublicKeyString()))
        {
            TestFramework.LogError("008", "Expected public key: " + certVals["PublicKeyString"] + ", found: " +
                cer.GetPublicKeyString());
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: SerialNumberString");
        if (!certVals["SerialNumberString"].Equals(cer.GetSerialNumberString()))
        {
            TestFramework.LogError("009", "Expected serial number: " + certVals["SerialNumberString"] + ", found: " + cer.GetSerialNumberString());
            retVal = false;
        }

        TestFramework.LogInformation("  Validating field: Subject");
        if (!certVals["Subject"].Equals(cer.Subject))
        {
            TestFramework.LogError("010", "Expected subject: " + certVals["Subject"] + ", found: " + cer.Subject);
            retVal = false;
        }

        TestFramework.LogInformation("  Retrieving field: CertHash");
        bytes = cer.GetCertHash();

        TestFramework.LogInformation("  Retrieving field: HashCode");
        hash = cer.GetHashCode();

        TestFramework.LogInformation("  Retrieving field: RawCertHash");
        bytes = cer.GetRawCertData();

        TestFramework.LogInformation("  Retrieving field: RawCertDataString");
        str = cer.GetRawCertDataString();

        TestFramework.LogInformation("  Retrieving field: SerialNumber");
        bytes = cer.GetSerialNumber();

        TestFramework.LogInformation("  Retrieving field: ToString()");
        str = cer.ToString();

        TestFramework.LogInformation("  Retrieving field: ToString(true)");
        str = cer.ToString(true);

        TestFramework.LogInformation("  Retrieving field: Handle");
        handle = GetHandle(cer);

        TestFramework.LogInformation("  Testing: Equality with a string");
        if (cer.Equals(str))
        {
            TestFramework.LogError("110", "X509Certificate \"equals\" a string?");
            retVal = false;
        }

        TestFramework.LogInformation("  Testing: Equality with itself(1)");
        if (!cer.Equals((object)cer))
        {
            TestFramework.LogError("120", "X509Certificate does not equal itself");
            retVal = false;
        }

        TestFramework.LogInformation("  Testing: Equality with itself(2)");
        if (!cer.Equals(cer))
        {
            TestFramework.LogError("130", "X509Certificate does not equal itself");
            retVal = false;
        }      

        return retVal;
    }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:101,代码来源:X509CertificateRunSuite.cs

示例2: CertificateCompare

        static public bool CertificateCompare(X509Certificate cert1, X509Certificate cert2)
        {
            if( cert1 == null || cert2 == null )
            {
                Log.Comment("One of the certificates is null");
                return false;
            }

            byte [] cert1Bytes = cert1.GetRawCertData();
            byte [] cert2Bytes = cert2.GetRawCertData();

            return CertificateCompare(cert1Bytes, cert2Bytes);
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:13,代码来源:Tools.cs

示例3: OnClientCertificateValidation

		bool OnClientCertificateValidation (X509Certificate certificate, int[] errors)
		{
			if (certificate == null)
				return true;
			X509Certificate2 cert = certificate as X509Certificate2;
			if (cert == null)
				cert = new X509Certificate2 (certificate.GetRawCertData ());
			client_cert = cert;
			client_cert_errors = errors;
			return true;
		}
开发者ID:GirlD,项目名称:mono,代码行数:11,代码来源:HttpConnection.cs

示例4: GetRawDataNewCert

        public MFTestResults GetRawDataNewCert()
        {
            MFTestResults testResult = MFTestResults.Fail;

            Log.Comment("Get the raw data from the valid certificate");

            try
            {
                X509Certificate cert = new X509Certificate(CertificatesAndCAs.newCert);
                byte[] rawCert = cert.GetRawCertData();

                if (Tools.CertificateCompare(CertificatesAndCAs.newCert, rawCert))
                    testResult = MFTestResults.Pass;
            }
            catch (Exception e)
            {
                Log.Comment("Incorrectly threw exception calling GetRawCertData: " + e.ToString());
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:22,代码来源:X509CertificateTests.cs

示例5: GetPublicKeyFromPfxOrP12

 private static byte[] GetPublicKeyFromPfxOrP12(string fullPathToCerFile)
 {
     X509Certificate cert = new X509Certificate(fullPathToCerFile);
     return cert.GetRawCertData();
 }
开发者ID:hariwashere,项目名称:JourneyCompass,代码行数:5,代码来源:CreateChildApplication.cs


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