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


C# X509Certificate.GetPublicKey方法代码示例

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


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

示例1: CertCheck

		private static bool CertCheck(object sender, 
		                              X509Certificate cert, 
		                              X509Chain chain, 
		                              SslPolicyErrors error)
		{
#if !BYPASS_SSL_CHECK
			if (cert == null)
			{
				Console.WriteLine("Warning: Certificate is null!");
				return false;
			}
			
			FileStream stream = Assembly.GetCallingAssembly().GetFile("PublicKey");
			byte[] bytes = new byte[stream.Length];
			stream.Read(bytes, 0, bytes.Length);
			
			if (bytes.Length < cert.GetPublicKey().Length)
				return false;
			
			for (int i = 0; i < bytes.Length; i++)
			{
				if (bytes[i] != cert.GetPublicKey()[i])
				{
					return false;
				}
			}
#endif
			return true;
		}
开发者ID:GUIpsp,项目名称:MultiMC,代码行数:29,代码来源:AppUtils.cs

示例2: PublicKeyEquals

        // Checks if two certificates have the same public key, keyalg, and keyparam. 
        internal static bool PublicKeyEquals( X509Certificate cert1, X509Certificate cert2 )
        {
            if (cert1 == null)
            { 
                return (cert2 == null);
            } 
            else if (cert2 == null) 
            {
                return false; 
            }

            byte[] publicKey1 = cert1.GetPublicKey();
            String keyAlg1 = cert1.GetKeyAlgorithm(); 
            byte[] keyAlgParam1 = cert1.GetKeyAlgorithmParameters();
            byte[] publicKey2 = cert2.GetPublicKey(); 
            String keyAlg2 = cert2.GetKeyAlgorithm(); 
            byte[] keyAlgParam2 = cert2.GetKeyAlgorithmParameters();
 
            // Keys are most likely to be different of the three components,
            // so check them first

            int len = publicKey1.Length; 
            if (len != publicKey2.Length) return(false);
            for (int i = 0; i < len; i++) { 
                if (publicKey1[i] != publicKey2[i]) return(false); 
            }
            if (!(keyAlg1.Equals(keyAlg2))) return(false); 
            len = keyAlgParam1.Length;
            if (keyAlgParam2.Length != len) return(false);
            for (int i = 0; i < len; i++) {
                if (keyAlgParam1[i] != keyAlgParam2[i]) return(false); 
            }
 
            return true; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:36,代码来源:Publisher.cs

示例3: ExtractValues

        internal void ExtractValues(string appParam, byte[] originalChallenge)
        {
            DataContractJsonSerializer jsonSerializerResponse = new DataContractJsonSerializer(typeof(ClientData));
            object objResponse = jsonSerializerResponse.ReadObject(new MemoryStream(Helpers.Base64UrlDecode(clientData)));
            ClientData clientDataObject = objResponse as ClientData;

            if (clientDataObject == null
                || !clientDataObject.origin.Equals(appParam)
                || !clientDataObject.typ.Equals("navigator.id.finishEnrollment")
                || !clientDataObject.challenge.Equals(Helpers.Base64UrlEncode(originalChallenge))
                )
                throw new Exception("clientData does not contain necessary fields");

            byte[] data = Helpers.Base64UrlDecode(registrationData);
            if (data[0] != 0x05)
                throw new Exception("Invalid registration data");

            var keyLen = 65;
            byte[] keyBytes = new byte[keyLen];
            Array.Copy(data, 1, keyBytes, 0, keyLen);
            publicKey = Helpers.Base64UrlEncode(keyBytes);

            int keyHandleLen = data[66];
            byte[] keyHandleBytes = new byte[keyHandleLen];
            Array.Copy(data, 1 + 1 + keyLen, keyHandleBytes, 0, keyHandleLen);
            keyHandle = Helpers.Base64UrlEncode(keyHandleBytes);

            int certLen = data.Length - 1 - 1 - keyLen - keyHandleLen; // temporary!
            byte[] certBytes = new byte[certLen];
            Array.Copy(data, 1 + 1 + keyLen + keyHandleLen, certBytes, 0, certLen);
            X509Certificate certObject = new X509Certificate(certBytes);
            certBytes = certObject.Export(X509ContentType.Cert);
            certLen = certBytes.Length;

            int sigLen = data.Length - 1 - 1 - keyLen - keyHandleLen - certLen;
            byte[] signatureBytes = new byte[sigLen];
            Array.Copy(data, data.Length - sigLen, signatureBytes, 0, sigLen);

            var bytesToVerify = new byte[] { 0x00 }
                .Concat(SHA256.Create().ComputeHash(new UTF8Encoding().GetBytes(appParam)))
                .Concat(SHA256.Create().ComputeHash(Helpers.Base64UrlDecode(clientData)))
                .Concat(keyHandleBytes)
                .Concat(keyBytes)
                .ToArray();

            var ecdsa = new ECDsaCng(CngKey.Import(FixKeyBytes(certObject.GetPublicKey()), CngKeyBlobFormat.EccPublicBlob))
            {
                HashAlgorithm = CngAlgorithm.Sha256
            };
            if (!ecdsa.VerifyData(bytesToVerify, FixSignatureBytes(signatureBytes)))
                throw new Exception("Signature is not valid");
        }
开发者ID:IAIK,项目名称:CrySIL,代码行数:52,代码来源:CrySilU2FResponse.cs

示例4: GetCertPublicKeySize

        public uint GetCertPublicKeySize(X509Certificate cert)
        {
            byte[] publickeyblob;
            byte[] encodedpubkey = cert.GetPublicKey(); //asn.1 encoded public key

            uint blobbytes = 0;
            if (verbose)
            {
                Console.WriteLine();
                showBytes("Encoded publickey", encodedpubkey);
                Console.WriteLine();
            }
            if (Win32.CryptDecodeObject(ENCODING_TYPE, RSA_CSP_PUBLICKEYBLOB, encodedpubkey, (uint)encodedpubkey.Length, 0, null, ref blobbytes))
            {
                publickeyblob = new byte[blobbytes];
                if (Win32.CryptDecodeObject(ENCODING_TYPE, RSA_CSP_PUBLICKEYBLOB, encodedpubkey, (uint)encodedpubkey.Length, 0, publickeyblob, ref blobbytes))
                    if (verbose)
                        showBytes("CryptoAPI publickeyblob", publickeyblob);
            }
            else
            {
                Console.WriteLine("Couldn't decode publickeyblob from certificate publickey");
                return 0;
            }

            PUBKEYBLOBHEADERS pkheaders = new PUBKEYBLOBHEADERS();
            int headerslength = Marshal.SizeOf(pkheaders);
            IntPtr buffer = Marshal.AllocHGlobal(headerslength);
            Marshal.Copy(publickeyblob, 0, buffer, headerslength);
            pkheaders = (PUBKEYBLOBHEADERS)Marshal.PtrToStructure(buffer, typeof(PUBKEYBLOBHEADERS));
            Marshal.FreeHGlobal(buffer);

            if (verbose)
            {
                Console.WriteLine("\n ---- PUBLICKEYBLOB headers ------");
                Console.WriteLine("  btype     {0}", pkheaders.bType);
                Console.WriteLine("  bversion  {0}", pkheaders.bVersion);
                Console.WriteLine("  reserved  {0}", pkheaders.reserved);
                Console.WriteLine("  aiKeyAlg  0x{0:x8}", pkheaders.aiKeyAlg);
                String magicstring = (new ASCIIEncoding()).GetString(BitConverter.GetBytes(pkheaders.magic));
                Console.WriteLine("  magic     0x{0:x8}     '{1}'", pkheaders.magic, magicstring);
                Console.WriteLine("  bitlen    {0}", pkheaders.bitlen);
                Console.WriteLine("  pubexp    {0}", pkheaders.pubexp);
                Console.WriteLine(" --------------------------------");
            }
            //-----  Get public key size in bits -------------
            this.certkeysize = pkheaders.bitlen;

            return this.certkeysize;
        }
开发者ID:olliencc,项目名称:WinBinaryAudit,代码行数:50,代码来源:CertificateSupport.cs

示例5: PublicKeyEquals

 internal static bool PublicKeyEquals(X509Certificate cert1, X509Certificate cert2)
 {
     if (cert1 == null)
     {
         return (cert2 == null);
     }
     if (cert2 == null)
     {
         return false;
     }
     byte[] publicKey = cert1.GetPublicKey();
     string keyAlgorithm = cert1.GetKeyAlgorithm();
     byte[] keyAlgorithmParameters = cert1.GetKeyAlgorithmParameters();
     byte[] buffer3 = cert2.GetPublicKey();
     string str2 = cert2.GetKeyAlgorithm();
     byte[] buffer4 = cert2.GetKeyAlgorithmParameters();
     int length = publicKey.Length;
     if (length != buffer3.Length)
     {
         return false;
     }
     for (int i = 0; i < length; i++)
     {
         if (publicKey[i] != buffer3[i])
         {
             return false;
         }
     }
     if (!keyAlgorithm.Equals(str2))
     {
         return false;
     }
     length = keyAlgorithmParameters.Length;
     if (buffer4.Length != length)
     {
         return false;
     }
     for (int j = 0; j < length; j++)
     {
         if (keyAlgorithmParameters[j] != buffer4[j])
         {
             return false;
         }
     }
     return true;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:Publisher.cs

示例6: Handle

 public string Handle(string msg)
 {
     var u2fRequest = JObject.Parse(msg);
     var challengeParam = Helpers.Base64UrlDecode(u2fRequest["challengeHash"].ToString());
     var appParam = Helpers.Base64UrlDecode(u2fRequest["appIdHash"].ToString());
     var crysilResponse = this.handler.ExecuteGenerateWrappedKey(u2fRequest["challengeHash"].ToString(), u2fRequest["appIdHash"].ToString(), null);
     var responseGenKey = JObject.Parse(crysilResponse);
     var payloadGenKey = responseGenKey["payload"];
     var certEncoded = Helpers.Base64UrlDecode(payloadGenKey["encodedX509Certificate"].ToString());
     var certificate = new X509Certificate(certEncoded);
     var keyEncoded = StripMetaData(certificate.GetPublicKey());
     var keyHandleBytes = Helpers.Base64UrlDecode(payloadGenKey["encodedRandom"].ToString());
     var signatureBytes = new byte[] { 0x00 }
         .Concat(appParam)
         .Concat(challengeParam)
         .Concat(keyHandleBytes)
         .Concat(keyEncoded)
         .ToArray();
     var responseStr = this.handler.ExecuteSignatureRequest(payloadGenKey["encodedWrappedKey"].ToString(),
         Helpers.Base64UrlEncode(signatureBytes));
     var responseSign = JObject.Parse(responseStr);
     var payloadSign = responseSign["payload"];
     var signature = Helpers.Base64UrlDecode(payloadSign["signedHashes"][0].ToString());
     var signatureData = new byte[] { 0x05 }
         .Concat(keyEncoded)
         .Concat(new byte[] { (byte)keyHandleBytes.Length })
         .Concat(keyHandleBytes)
         .Concat(certEncoded)
         .Concat(signature)
         .ToArray();
     var fromU2FActor = BytesContains(signature, keyHandleBytes) && BytesContains(signature, certEncoded);
     if (fromU2FActor)
     {
         signatureData = signature;
     }
     var response = new JObject
     {
         ["registrationData"] = Helpers.Base64UrlEncode(signatureData)
     };
     return response.ToString();
 }
开发者ID:IAIK,项目名称:CrySIL,代码行数:41,代码来源:RegisterInternalHandler.cs

示例7: Certificate3

public void Certificate3 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x03,0x4E,0x30,0x82,0x02,0xB7,0xA0,0x03,0x02,0x01,0x02,0x02,0x20,0x03,0x53,0xD7,0x8B,0xDB,0x3E,0x16,0x15,0x80,0x55,0xC4,0x05,0x40,0x02,0x73,0x4D,0x0C,0x20,0xF8,0x0D,0x88,0x00,0x5F,0x65,0x7A,0xAC,0xBA,0x86,0xBD,0x1C,0xD7,0xE4,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x30,0x49,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x43,0x43,0x41,0x20,0x2D,0x20,0x55,0x6E,0x69,0x71,0x75,0x65,0x20,
		0x49,0x44,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x03,0x13,0x17,0x42,0x72,0x61,0x6E,0x64,0x20,0x4E,0x61,0x6D,0x65,0x3A,0x50,0x72,0x6F,0x64,0x75,0x63,0x74,0x20,0x54,0x79,0x70,0x65,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x38,0x30,0x37,0x30,0x30,0x30,0x30,0x30,0x30,0x5A,0x17,0x0D,0x39,0x36,0x30,0x38,0x33,0x31,0x32,0x33,0x35,0x39,0x35,0x39,0x5A,0x30,0x6E,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x10,0x30,0x0E,0x06,0x03,0x55,0x04,0x0A,0x13,0x07,0x42,0x72,0x61,0x6E,0x64,0x49,
		0x44,0x31,0x26,0x30,0x24,0x06,0x03,0x55,0x04,0x0B,0x13,0x1D,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x46,0x69,0x6E,0x61,0x6E,0x63,0x69,0x61,0x6C,0x20,0x49,0x6E,0x73,0x74,0x69,0x74,0x75,0x74,0x69,0x6F,0x6E,0x31,0x25,0x30,0x23,0x06,0x03,0x55,0x04,0x03,0x13,0x1C,0x30,0x2B,0x57,0x4B,0x4A,0x78,0x2B,0x77,0x59,0x45,0x5A,0x61,0x62,0x53,0x53,0x50,0x56,0x58,0x39,0x6B,0x4C,0x73,0x6E,0x78,0x39,0x32,0x73,0x3D,0x30,0x5C,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x4B,0x00,
		0x30,0x48,0x02,0x41,0x00,0xAC,0xC4,0x0E,0x05,0x25,0xBC,0xEA,0xEF,0x0C,0x22,0x7F,0xC4,0x0C,0x4A,0x69,0x31,0x00,0xF9,0x3F,0xE9,0xE1,0x6C,0x54,0x97,0x77,0x4E,0x18,0xC6,0x4A,0x95,0xE0,0xD4,0x58,0x29,0x5C,0x17,0x5D,0x1D,0x1E,0x56,0xBC,0x49,0x3D,0xE0,0xF9,0x9F,0xBB,0x01,0xF9,0x86,0xB6,0xA6,0x95,0xDD,0xE1,0x04,0x32,0x01,0x52,0x4E,0x8F,0x86,0x30,0xF7,0x02,0x03,0x01,0x00,0x01,0xA3,0x82,0x01,0x44,0x30,0x82,0x01,0x40,0x30,0x5C,0x06,0x03,0x55,0x1D,0x23,0x04,0x55,0x30,0x53,0x81,0x4B,0x84,0x49,0x31,0x0B,0x30,
		0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x43,0x43,0x41,0x20,0x2D,0x20,0x55,0x6E,0x69,0x71,0x75,0x65,0x20,0x49,0x44,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x03,0x13,0x17,0x42,0x72,0x61,0x6E,0x64,0x20,0x4E,0x61,0x6D,0x65,0x3A,0x50,0x72,0x6F,0x64,0x75,0x63,0x74,0x20,0x54,0x79,0x70,0x65,0x82,0x04,0x32,0x06,0xAC,0x10,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x07,0x80,0x30,0x2E,0x06,0x03,0x55,0x1D,0x10,0x01,
		0x01,0xFF,0x04,0x24,0x30,0x22,0x80,0x0F,0x31,0x39,0x39,0x36,0x30,0x38,0x30,0x37,0x30,0x37,0x34,0x39,0x30,0x30,0x5A,0x81,0x0F,0x31,0x39,0x39,0x36,0x30,0x39,0x30,0x37,0x30,0x37,0x34,0x39,0x30,0x30,0x5A,0x30,0x18,0x06,0x03,0x55,0x1D,0x20,0x04,0x11,0x30,0x0F,0x30,0x0D,0x06,0x0B,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x01,0x07,0x01,0x01,0x30,0x0C,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x02,0x30,0x00,0x30,0x14,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x02,0x03,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,
		0x07,0x80,0x30,0x62,0x06,0x09,0x60,0x86,0x48,0x01,0x86,0xF8,0x45,0x02,0x07,0x01,0x01,0xFF,0x04,0x52,0x30,0x50,0x04,0x14,0x33,0x39,0x38,0x32,0x33,0x39,0x38,0x37,0x32,0x33,0x37,0x38,0x39,0x31,0x33,0x34,0x39,0x37,0x38,0x32,0x30,0x09,0x06,0x05,0x2B,0x0D,0x03,0x02,0x1A,0x05,0x00,0x16,0x0F,0x74,0x65,0x72,0x73,0x65,0x20,0x73,0x74,0x61,0x74,0x65,0x6D,0x65,0x6E,0x74,0x1D,0x00,0x16,0x1A,0x67,0x65,0x74,0x73,0x65,0x74,0x2D,0x63,0x65,0x6E,0x74,0x65,0x72,0x40,0x76,0x65,0x72,0x69,0x73,0x69,0x67,0x6E,0x2E,0x63,
		0x6F,0x6D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x05,0x05,0x00,0x03,0x81,0x81,0x00,0x1D,0x6C,0x90,0xF2,0x02,0x10,0xD5,0xA0,0x7B,0xEB,0x07,0x14,0x1D,0xAE,0x2C,0xD5,0xB1,0x4C,0x23,0x30,0xB2,0x31,0x7F,0x96,0x3C,0xD1,0x41,0x11,0xEA,0x08,0x0D,0x80,0x5F,0x46,0x66,0x9D,0x0A,0xF2,0x91,0xE8,0x7C,0xCE,0xC0,0xAD,0xE6,0x96,0x19,0x9C,0x26,0xC3,0x4E,0xEB,0x6F,0xF4,0x4A,0x69,0x4C,0xFE,0x4C,0x76,0xB3,0x51,0xCA,0x44,0x03,0xFC,0xD4,0xF4,0xF9,0x32,0x2A,0xAE,0x03,0x1B,0x5F,0xA6,0xBF,0x16,0x61,
		0xA0,0x07,0x86,0x85,0xA7,0xD6,0x0D,0xEF,0x88,0x9B,0x2A,0xBA,0xB8,0xD4,0x5C,0x94,0x7C,0x63,0xE1,0xE0,0x69,0xEB,0x3D,0x2F,0xC1,0x71,0x56,0x47,0x55,0x4B,0xB8,0xFD,0xCD,0xD6,0xC7,0x6F,0xA7,0x47,0xE9,0x43,0x91,0x2E,0xCF,0x93,0xA4,0x05,0x18,0xC5,0x98 };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assertion.Assert ("Equals", x509.Equals (clone));
	Assertion.Assert ("Equals", clone.Equals (x509));

	FileStream fs = File.OpenWrite ("temp.cer");
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile ("temp.cer");
	Assertion.Assert ("Equals", disk.Equals (clone));
	Assertion.Assert ("Equals", disk.Equals (x509));
	byte[] hash = { 0x39,0x5F,0xBB,0xFC,0x14,0x89,0x33,0x27,0x76,0x89,0xB7,0x59,0x3A,0x7D,0x1C,0xFF,0xF1,0x56,0xF1,0x62 };
	AssertEquals ("GetCertHash", hash, x509.GetCertHash ());
	Assertion.AssertEquals ("GetCertHashString", "395FBBFC148933277689B7593A7D1CFFF156F162", x509.GetCertHashString ());
	Assertion.AssertEquals ("GetEffectiveDateString", "08/06/1996 16:00:00", x509.GetEffectiveDateString ());
	Assertion.AssertEquals ("GetExpirationDateString", "08/31/1996 15:59:59", x509.GetExpirationDateString ());
	Assertion.AssertEquals ("GetFormat", "X509", x509.GetFormat ());
	Assertion.AssertEquals ("GetHashCode", 962575356, x509.GetHashCode ());
	Assertion.AssertEquals ("GetIssuerName", "C=US, O=CCA - Unique ID, CN=Brand Name:Product Type", x509.GetIssuerName ());
	Assertion.AssertEquals ("GetKeyAlgorithm", "1.2.840.113549.1.1.1", x509.GetKeyAlgorithm ());
	byte[] keyparams = { 0x05,0x00 };
	AssertEquals ("GetKeyAlgorithmParameters", keyparams, x509.GetKeyAlgorithmParameters ());
	Assertion.AssertEquals ("GetKeyAlgorithmParametersString", "0500", x509.GetKeyAlgorithmParametersString ());
	Assertion.AssertEquals ("GetName", "C=US, O=BrandID, OU=Issuing Financial Institution, CN=\"0+WKJx+wYEZabSSPVX9kLsnx92s=\"", x509.GetName ());
	byte[] pubkey = { 0x30,0x48,0x02,0x41,0x00,0xAC,0xC4,0x0E,0x05,0x25,0xBC,0xEA,0xEF,0x0C,0x22,0x7F,0xC4,0x0C,0x4A,0x69,0x31,0x00,0xF9,0x3F,0xE9,0xE1,0x6C,0x54,0x97,0x77,0x4E,0x18,0xC6,0x4A,0x95,0xE0,0xD4,0x58,0x29,0x5C,0x17,0x5D,0x1D,0x1E,0x56,0xBC,0x49,0x3D,0xE0,0xF9,0x9F,0xBB,0x01,0xF9,0x86,0xB6,0xA6,0x95,0xDD,0xE1,0x04,0x32,0x01,0x52,0x4E,0x8F,0x86,0x30,0xF7,0x02,0x03,0x01,0x00,0x01 };
	AssertEquals ("GetPublicKey", pubkey, x509.GetPublicKey ());
	Assertion.AssertEquals ("GetPublicKeyString", "3048024100ACC40E0525BCEAEF0C227FC40C4A693100F93FE9E16C5497774E18C64A95E0D458295C175D1D1E56BC493DE0F99FBB01F986B6A695DDE1043201524E8F8630F70203010001", x509.GetPublicKeyString ());
	AssertEquals ("GetRawCertData", cert, x509.GetRawCertData ());
	Assertion.AssertEquals ("GetRawCertDataString", ToString (cert), x509.GetRawCertDataString ());
	byte[] serial = { 0xE4,0xD7,0x1C,0xBD,0x86,0xBA,0xAC,0x7A,0x65,0x5F,0x00,0x88,0x0D,0xF8,0x20,0x0C,0x4D,0x73,0x02,0x40,0x05,0xC4,0x55,0x80,0x15,0x16,0x3E,0xDB,0x8B,0xD7,0x53,0x03 };
	AssertEquals ("GetSerialNumber", serial, x509.GetSerialNumber ());
	Assertion.AssertEquals ("GetSerialNumberString", "E4D71CBD86BAAC7A655F00880DF8200C4D73024005C4558015163EDB8BD75303", x509.GetSerialNumberString ());
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x42,0x72,0x61,0x6E,0x64,0x49,0x44,0x2C,0x20,0x4F,0x55,0x3D,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x46,0x69,0x6E,0x61,0x6E,0x63,0x69,0x61,0x6C,0x20,0x49,0x6E,0x73,0x74,0x69,0x74,0x75,0x74,0x69,0x6F,0x6E,0x2C,0x20,0x43,0x4E,0x3D,0x22,0x30,0x2B,0x57,0x4B,0x4A,0x78,0x2B,0x77,
		0x59,0x45,0x5A,0x61,0x62,0x53,0x53,0x50,0x56,0x58,0x39,0x6B,0x4C,0x73,0x6E,0x78,0x39,0x32,0x73,0x3D,0x22,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x43,0x43,0x41,0x20,0x2D,0x20,0x55,0x6E,0x69,0x71,0x75,0x65,0x20,0x49,0x44,0x2C,0x20,0x43,0x4E,0x3D,0x42,0x72,0x61,0x6E,0x64,0x20,0x4E,0x61,0x6D,0x65,0x3A,0x50,0x72,0x6F,0x64,0x75,0x63,0x74,0x20,0x54,0x79,0x70,0x65,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,
		0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,0x20,0x45,0x34,0x44,0x37,0x31,0x43,0x42,0x44,0x38,0x36,0x42,0x41,0x41,0x43,0x37,0x41,0x36,0x35,0x35,0x46,0x30,0x30,0x38,0x38,0x30,0x44,0x46,0x38,0x32,0x30,0x30,0x43,0x34,0x44,0x37,0x33,0x30,0x32,0x34,0x30,0x30,0x35,0x43,0x34,0x35,0x35,0x38,0x30,0x31,0x35,0x31,0x36,0x33,0x45,
		0x44,0x42,0x38,0x42,0x44,0x37,0x35,0x33,0x30,0x33,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x34,0x38,0x30,0x32,0x34,0x31,0x30,0x30,0x41,0x43,0x43,0x34,0x30,0x45,0x30,0x35,0x32,0x35,0x42,0x43,0x45,0x41,0x45,0x46,0x30,0x43,0x32,0x32,0x37,0x46,0x43,0x34,0x30,0x43,0x34,0x41,0x36,0x39,
		0x33,0x31,0x30,0x30,0x46,0x39,0x33,0x46,0x45,0x39,0x45,0x31,0x36,0x43,0x35,0x34,0x39,0x37,0x37,0x37,0x34,0x45,0x31,0x38,0x43,0x36,0x34,0x41,0x39,0x35,0x45,0x30,0x44,0x34,0x35,0x38,0x32,0x39,0x35,0x43,0x31,0x37,0x35,0x44,0x31,0x44,0x31,0x45,0x35,0x36,0x42,0x43,0x34,0x39,0x33,0x44,0x45,0x30,0x46,0x39,0x39,0x46,0x42,0x42,0x30,0x31,0x46,0x39,0x38,0x36,0x42,0x36,0x41,0x36,0x39,0x35,0x44,0x44,0x45,0x31,0x30,0x34,0x33,0x32,0x30,0x31,0x35,0x32,0x34,0x45,0x38,0x46,0x38,0x36,0x33,0x30,0x46,0x37,0x30,0x32,
		0x30,0x33,0x30,0x31,0x30,0x30,0x30,0x31,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assertion.AssertEquals ("ToString(true)", tsa, x509.ToString (true));
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:56,代码来源:X509CertificateTest.cs

示例8: ConstructorIntPtr

		public void ConstructorIntPtr ()
		{
			byte[] cert = { 0x30,0x82,0x01,0xFF,0x30,0x82,0x01,0x6C,0x02,0x05,0x02,0x72,0x00,0x06,0xE8,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
				0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x37,0x5A,0x17,0x0D,0x39,0x37,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x36,0x5A,0x30,0x61,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
				0x55,0x04,0x0A,0x13,0x0B,0x43,0x6F,0x6D,0x6D,0x65,0x72,0x63,0x65,0x4E,0x65,0x74,0x31,0x27,0x30,0x25,0x06,0x03,0x55,0x04,0x0B,0x13,0x1E,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x70,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x5F,0x00,0x30,0x5C,0x02,0x55,0x2D,0x58,0xE9,0xBF,0xF0,0x31,0xCD,0x79,0x06,0x50,0x5A,0xD5,0x9E,0x0E,0x2C,0xE6,0xC2,0xF7,0xF9,
				0xD2,0xCE,0x55,0x64,0x85,0xB1,0x90,0x9A,0x92,0xB3,0x36,0xC1,0xBC,0xEA,0xC8,0x23,0xB7,0xAB,0x3A,0xA7,0x64,0x63,0x77,0x5F,0x84,0x22,0x8E,0xE5,0xB6,0x45,0xDD,0x46,0xAE,0x0A,0xDD,0x00,0xC2,0x1F,0xBA,0xD9,0xAD,0xC0,0x75,0x62,0xF8,0x95,0x82,0xA2,0x80,0xB1,0x82,0x69,0xFA,0xE1,0xAF,0x7F,0xBC,0x7D,0xE2,0x7C,0x76,0xD5,0xBC,0x2A,0x80,0xFB,0x02,0x03,0x01,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x03,0x7E,0x00,0x54,0x20,0x67,0x12,0xBB,0x66,0x14,0xC3,0x26,0x6B,0x7F,
				0xDA,0x4A,0x25,0x4D,0x8B,0xE0,0xFD,0x1E,0x53,0x6D,0xAC,0xA2,0xD0,0x89,0xB8,0x2E,0x90,0xA0,0x27,0x43,0xA4,0xEE,0x4A,0x26,0x86,0x40,0xFF,0xB8,0x72,0x8D,0x1E,0xE7,0xB7,0x77,0xDC,0x7D,0xD8,0x3F,0x3A,0x6E,0x55,0x10,0xA6,0x1D,0xB5,0x58,0xF2,0xF9,0x0F,0x2E,0xB4,0x10,0x55,0x48,0xDC,0x13,0x5F,0x0D,0x08,0x26,0x88,0xC9,0xAF,0x66,0xF2,0x2C,0x9C,0x6F,0x3D,0xC3,0x2B,0x69,0x28,0x89,0x40,0x6F,0x8F,0x35,0x3B,0x9E,0xF6,0x8E,0xF1,0x11,0x17,0xFB,0x0C,0x98,0x95,0xA1,0xC2,0xBA,0x89,0x48,0xEB,0xB4,0x06,0x6A,0x22,0x54,
				0xD7,0xBA,0x18,0x3A,0x48,0xA6,0xCB,0xC2,0xFD,0x20,0x57,0xBC,0x63,0x1C };

			// will only work on Windows (MS or Mono)
			// this isn't much of a problem because the structure CERT_CONTEXT (IntPtr)
			// is specific to CryptoAPI/Windows.
			IntPtr handle = IntPtr.Zero;

			if (Path.DirectorySeparatorChar == '\\') {
				handle = GetHandle (cert);
			} else {
				handle = GetHandleEx (cert);
			}

			X509Certificate x509 = new X509Certificate (handle);
			byte[] hash = { 0xD6,0x2F,0x48,0xD0,0x13,0xEE,0x7F,0xB5,0x8B,0x79,0x07,0x45,0x12,0x67,0x0D,0x9C,0x5B,0x3A,0x5D,0xA9 };
			Assert.AreEqual (hash, x509.GetCertHash (), "GetCertHash");
			Assert.AreEqual ("D62F48D013EE7FB58B79074512670D9C5B3A5DA9", x509.GetCertHashString (), "GetCertHashString");
			DateTime from = DateTime.ParseExact (x509.GetEffectiveDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
			Assert.AreEqual ("03/12/1996 18:38:47", from.ToString (), "GetEffectiveDateString");
			DateTime until = DateTime.ParseExact (x509.GetExpirationDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
			Assert.AreEqual ("03/12/1997 18:38:46", until.ToString (), "GetExpirationDateString");
			Assert.AreEqual ("X509", x509.GetFormat (), "GetFormat");
			Assert.AreEqual (-701544240, x509.GetHashCode (), "GetHashCode");
			Assert.AreEqual ("C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetIssuerName (), "GetIssuerName");
			Assert.AreEqual ("1.2.840.113549.1.1.1", x509.GetKeyAlgorithm (), "GetKeyAlgorithm");
			byte[] keyparams = { 0x05,0x00 };
			Assert.AreEqual (keyparams, x509.GetKeyAlgorithmParameters (), "GetKeyAlgorithmParameters");
			Assert.AreEqual ("0500", x509.GetKeyAlgorithmParametersString (), "GetKeyAlgorithmParametersString");
			Assert.AreEqual ("C=US, S=California, O=CommerceNet, OU=Server Certification Authority", x509.GetName (), "GetName");
			byte[] pubkey = { 0x30,0x5C,0x02,0x55,0x2D,0x58,0xE9,0xBF,0xF0,0x31,0xCD,0x79,0x06,0x50,0x5A,0xD5,0x9E,0x0E,0x2C,0xE6,0xC2,0xF7,0xF9,0xD2,0xCE,0x55,0x64,0x85,0xB1,0x90,0x9A,0x92,0xB3,0x36,0xC1,0xBC,0xEA,0xC8,0x23,0xB7,0xAB,0x3A,0xA7,0x64,0x63,0x77,0x5F,0x84,0x22,0x8E,0xE5,0xB6,0x45,0xDD,0x46,0xAE,0x0A,0xDD,0x00,0xC2,0x1F,0xBA,0xD9,0xAD,0xC0,0x75,0x62,0xF8,0x95,0x82,0xA2,0x80,0xB1,0x82,0x69,0xFA,0xE1,0xAF,0x7F,0xBC,0x7D,0xE2,0x7C,0x76,0xD5,0xBC,0x2A,0x80,0xFB,0x02,0x03,0x01,0x00,0x01 };
			Assert.AreEqual (pubkey, x509.GetPublicKey (), "GetPublicKey");
			Assert.AreEqual ("305C02552D58E9BFF031CD7906505AD59E0E2CE6C2F7F9D2CE556485B1909A92B336C1BCEAC823B7AB3AA76463775F84228EE5B645DD46AE0ADD00C21FBAD9ADC07562F89582A280B18269FAE1AF7FBC7DE27C76D5BC2A80FB0203010001", x509.GetPublicKeyString (), "GetPublicKeyString");
			Assert.AreEqual (cert, x509.GetRawCertData (), "GetRawCertData");
			Assert.AreEqual (ToString (cert), x509.GetRawCertDataString (), "GetRawCertDataString");
			byte[] serial = { 0xE8,0x06,0x00,0x72,0x02 };
			Assert.AreEqual (serial, x509.GetSerialNumber (), "GetSerialNumber");
			Assert.AreEqual ("02720006E8", x509.GetSerialNumberString (), "GetSerialNumberString");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:45,代码来源:X509CapiTest.cs

示例9: Certificate11

public void Certificate11 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x01,0xF5,0x30,0x82,0x01,0x5E,0x02,0x01,0x00,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x45,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x47,0x54,0x45,0x20,0x43,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x31,0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x13,0x13,0x47,0x54,0x45,0x20,0x43,0x79,0x62,0x65,0x72,0x54,0x72,0x75,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x30,0x1A,0x17,0x0B,
		0x39,0x36,0x30,0x32,0x32,0x33,0x31,0x39,0x31,0x35,0x5A,0x17,0x0B,0x39,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x39,0x5A,0x30,0x45,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x18,0x30,0x16,0x06,0x03,0x55,0x04,0x0A,0x13,0x0F,0x47,0x54,0x45,0x20,0x43,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x31,0x1C,0x30,0x1A,0x06,0x03,0x55,0x04,0x03,0x13,0x13,0x47,0x54,0x45,0x20,0x43,0x79,0x62,0x65,0x72,0x54,0x72,0x75,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x30,0x81,0x9F,0x30,0x0D,
		0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8D,0x00,0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xB8,0xE6,0x4F,0xBA,0xDB,0x98,0x7C,0x71,0x7C,0xAF,0x44,0xB7,0xD3,0x0F,0x46,0xD9,0x64,0xE5,0x93,0xC1,0x42,0x8E,0xC7,0xBA,0x49,0x8D,0x35,0x2D,0x7A,0xE7,0x8B,0xBD,0xE5,0x05,0x31,0x59,0xC6,0xB1,0x2F,0x0A,0x0C,0xFB,0x9F,0xA7,0x3F,0xA2,0x09,0x66,0x84,0x56,0x1E,0x37,0x29,0x1B,0x87,0xE9,0x7E,0x0C,0xCA,0x9A,0x9F,0xA5,0x7F,0xF5,0x15,0x94,0xA3,0xD5,0xA2,0x46,0x82,0xD8,0x68,0x4C,0xD1,0x37,
		0x15,0x06,0x68,0xAF,0xBD,0xF8,0xB0,0xB3,0xF0,0x29,0xF5,0x95,0x5A,0x09,0x16,0x61,0x77,0x0A,0x22,0x25,0xD4,0x4F,0x45,0xAA,0xC7,0xBD,0xE5,0x96,0xDF,0xF9,0xD4,0xA8,0x8E,0x42,0xCC,0x24,0xC0,0x1E,0x91,0x27,0x4A,0xB5,0x6D,0x06,0x80,0x63,0x39,0xC4,0xA2,0x5E,0x38,0x03,0x02,0x03,0x01,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x34,0x9B,0x09,0x05,0x9D,0x42,0x48,0x7F,0x7C,0x24,0x8E,0xC2,0x88,0x65,0x78,0x6B,0x4D,0x2A,0x0E,0xAF,0xED,0xED,0xF0,0x6A,
		0x2D,0x37,0xEB,0x57,0x51,0x0E,0x8A,0xAD,0x2D,0x13,0x02,0xA1,0x40,0x6A,0x41,0xF6,0x69,0x72,0xBF,0x0F,0xA0,0x4E,0x55,0xE7,0x82,0xA6,0x57,0x91,0x8B,0x5D,0x43,0x08,0xC9,0xF8,0x71,0x07,0x82,0xE3,0x3E,0x14,0x01,0x24,0x0C,0x39,0xEB,0x61,0x22,0xF7,0xA2,0x0B,0x42,0x23,0x14,0xCA,0x10,0x18,0x36,0x0A,0x05,0xD1,0xC8,0x4A,0xF1,0x0E,0xB3,0xFD,0x00,0xD0,0xC6,0xEE,0x55,0xF2,0x4C,0x62,0xB4,0x19,0x73,0x1F,0x48,0x18,0xD8,0xB0,0x4E,0xB0,0x75,0xBC,0xB9,0x84,0x8B,0x1F,0x96,0x8A,0x83,0xF1,0xA0,0x1A,0xA2,0xED,0xFF,0x87,
		0x8C,0xA3,0x4F,0xA2 };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assert.IsTrue (x509.Equals (clone), "Equals");
	Assert.IsTrue (clone.Equals (x509), "Equals");

	FileStream fs = File.OpenWrite (temp_certificate_filename);
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile (temp_certificate_filename);
	Assert.IsTrue (disk.Equals (clone), "Equals");
	Assert.IsTrue (disk.Equals (x509), "Equals");
	byte[] hash = { 0xA2,0x75,0xE0,0x26,0xAC,0xD8,0x54,0x79,0x4A,0x4A,0xA2,0xCB,0x53,0xF6,0x62,0x33,0x12,0x9C,0x55,0xB6 };
	Assert.AreEqual (hash, x509.GetCertHash (), "GetCertHash");
	Assert.AreEqual ("A275E026ACD854794A4AA2CB53F66233129C55B6", x509.GetCertHashString (), "GetCertHashString");
#if NET_2_0
	DateTime from = DateTime.ParseExact (x509.GetEffectiveDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("02/23/1996 19:15:00", from.ToString (), "GetEffectiveDateString");
	DateTime until = DateTime.ParseExact (x509.GetExpirationDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("12/31/1999 23:59:00", until.ToString (), "GetExpirationDateString");
#else
	// fx 1.x has a bug where the returned dates were always in the Seattle time zone
	Assert.AreEqual ("02/23/1996 11:15:00", x509.GetEffectiveDateString (), "GetEffectiveDateString");
	Assert.AreEqual ("12/31/1999 15:59:00", x509.GetExpirationDateString (), "GetExpirationDateString");
	// which was making it easier to test the dates ;-)
#endif
	Assert.AreEqual ("X509", x509.GetFormat (), "GetFormat");
	Assert.AreEqual (-1569333210, x509.GetHashCode (), "GetHashCode");
	Assert.AreEqual ("C=US, O=GTE Corporation, CN=GTE CyberTrust Root", x509.GetIssuerName (), "GetIssuerName");
	Assert.AreEqual ("1.2.840.113549.1.1.1", x509.GetKeyAlgorithm (), "GetKeyAlgorithm");
	byte[] keyparams = { 0x05,0x00 };
	Assert.AreEqual (keyparams, x509.GetKeyAlgorithmParameters (), "GetKeyAlgorithmParameters");
	Assert.AreEqual ("0500", x509.GetKeyAlgorithmParametersString (), "GetKeyAlgorithmParametersString");
	Assert.AreEqual ("C=US, O=GTE Corporation, CN=GTE CyberTrust Root", x509.GetName (), "GetName");
	byte[] pubkey = { 0x30,0x81,0x89,0x02,0x81,0x81,0x00,0xB8,0xE6,0x4F,0xBA,0xDB,0x98,0x7C,0x71,0x7C,0xAF,0x44,0xB7,0xD3,0x0F,0x46,0xD9,0x64,0xE5,0x93,0xC1,0x42,0x8E,0xC7,0xBA,0x49,0x8D,0x35,0x2D,0x7A,0xE7,0x8B,0xBD,0xE5,0x05,0x31,0x59,0xC6,0xB1,0x2F,0x0A,0x0C,0xFB,0x9F,0xA7,0x3F,0xA2,0x09,0x66,0x84,0x56,0x1E,0x37,0x29,0x1B,0x87,0xE9,0x7E,0x0C,0xCA,0x9A,0x9F,0xA5,0x7F,0xF5,0x15,0x94,0xA3,0xD5,0xA2,0x46,0x82,0xD8,0x68,0x4C,0xD1,0x37,0x15,0x06,0x68,0xAF,0xBD,0xF8,0xB0,0xB3,0xF0,0x29,0xF5,0x95,0x5A,0x09,0x16,0x61,0x77,0x0A,
		0x22,0x25,0xD4,0x4F,0x45,0xAA,0xC7,0xBD,0xE5,0x96,0xDF,0xF9,0xD4,0xA8,0x8E,0x42,0xCC,0x24,0xC0,0x1E,0x91,0x27,0x4A,0xB5,0x6D,0x06,0x80,0x63,0x39,0xC4,0xA2,0x5E,0x38,0x03,0x02,0x03,0x01,0x00,0x01 };
	Assert.AreEqual (pubkey, x509.GetPublicKey (), "GetPublicKey");
	Assert.AreEqual ("30818902818100B8E64FBADB987C717CAF44B7D30F46D964E593C1428EC7BA498D352D7AE78BBDE5053159C6B12F0A0CFB9FA73FA2096684561E37291B87E97E0CCA9A9FA57FF51594A3D5A24682D8684CD137150668AFBDF8B0B3F029F5955A091661770A2225D44F45AAC7BDE596DFF9D4A88E42CC24C01E91274AB56D06806339C4A25E38030203010001", x509.GetPublicKeyString (), "GetPublicKeyString");
	Assert.AreEqual (cert, x509.GetRawCertData (), "GetRawCertData");
	Assert.AreEqual (ToString (cert), x509.GetRawCertDataString (), "GetRawCertDataString");
	byte[] serial = { 0x00 };
	Assert.AreEqual (serial, x509.GetSerialNumber (), "GetSerialNumber");
	Assert.AreEqual ("00", x509.GetSerialNumberString (), "GetSerialNumberString");
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x47,0x54,0x45,0x20,0x43,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x2C,0x20,0x43,0x4E,0x3D,0x47,0x54,0x45,0x20,0x43,0x79,0x62,0x65,0x72,0x54,0x72,0x75,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,
		0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x47,0x54,0x45,0x20,0x43,0x6F,0x72,0x70,0x6F,0x72,0x61,0x74,0x69,0x6F,0x6E,0x2C,0x20,0x43,0x4E,0x3D,0x47,0x54,0x45,0x20,0x43,0x79,0x62,0x65,0x72,0x54,0x72,0x75,0x73,0x74,0x20,0x52,0x6F,0x6F,0x74,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,
		0x65,0x72,0x3A,0x20,0x20,0x30,0x30,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x38,0x31,0x38,0x39,0x30,0x32,0x38,0x31,0x38,0x31,0x30,0x30,0x42,0x38,0x45,0x36,0x34,0x46,0x42,0x41,0x44,0x42,0x39,0x38,0x37,0x43,0x37,0x31,0x37,0x43,0x41,0x46,0x34,0x34,0x42,0x37,0x44,0x33,0x30,0x46,0x34,
		0x36,0x44,0x39,0x36,0x34,0x45,0x35,0x39,0x33,0x43,0x31,0x34,0x32,0x38,0x45,0x43,0x37,0x42,0x41,0x34,0x39,0x38,0x44,0x33,0x35,0x32,0x44,0x37,0x41,0x45,0x37,0x38,0x42,0x42,0x44,0x45,0x35,0x30,0x35,0x33,0x31,0x35,0x39,0x43,0x36,0x42,0x31,0x32,0x46,0x30,0x41,0x30,0x43,0x46,0x42,0x39,0x46,0x41,0x37,0x33,0x46,0x41,0x32,0x30,0x39,0x36,0x36,0x38,0x34,0x35,0x36,0x31,0x45,0x33,0x37,0x32,0x39,0x31,0x42,0x38,0x37,0x45,0x39,0x37,0x45,0x30,0x43,0x43,0x41,0x39,0x41,0x39,0x46,0x41,0x35,0x37,0x46,0x46,0x35,0x31,
		0x35,0x39,0x34,0x41,0x33,0x44,0x35,0x41,0x32,0x34,0x36,0x38,0x32,0x44,0x38,0x36,0x38,0x34,0x43,0x44,0x31,0x33,0x37,0x31,0x35,0x30,0x36,0x36,0x38,0x41,0x46,0x42,0x44,0x46,0x38,0x42,0x30,0x42,0x33,0x46,0x30,0x32,0x39,0x46,0x35,0x39,0x35,0x35,0x41,0x30,0x39,0x31,0x36,0x36,0x31,0x37,0x37,0x30,0x41,0x32,0x32,0x32,0x35,0x44,0x34,0x34,0x46,0x34,0x35,0x41,0x41,0x43,0x37,0x42,0x44,0x45,0x35,0x39,0x36,0x44,0x46,0x46,0x39,0x44,0x34,0x41,0x38,0x38,0x45,0x34,0x32,0x43,0x43,0x32,0x34,0x43,0x30,0x31,0x45,0x39,
		0x31,0x32,0x37,0x34,0x41,0x42,0x35,0x36,0x44,0x30,0x36,0x38,0x30,0x36,0x33,0x33,0x39,0x43,0x34,0x41,0x32,0x35,0x45,0x33,0x38,0x30,0x33,0x30,0x32,0x30,0x33,0x30,0x31,0x30,0x30,0x30,0x31,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assert.AreEqual (tsa, x509.ToString (true), "ToString(true)");
#if NET_2_0
	Assert.AreEqual ("CN=GTE CyberTrust Root, O=GTE Corporation, C=US", x509.Issuer, "Issuer");
	Assert.AreEqual ("CN=GTE CyberTrust Root, O=GTE Corporation, C=US", x509.Subject, "Subject");
#endif
}
开发者ID:nlhepler,项目名称:mono,代码行数:67,代码来源:X509CertificateTest.cs

示例10: Certificate4

public void Certificate4 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x02,0x29,0x30,0x82,0x01,0x96,0x02,0x05,0x02,0x41,0x00,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
		0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x34,0x31,0x31,0x30,0x39,0x32,0x33,0x35,0x34,0x31,0x37,0x5A,0x17,0x0D,0x39,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x34,0x31,0x37,0x5A,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,
		0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x81,0x9B,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x89,0x00,0x30,0x81,0x85,0x02,0x7E,0x00,0x92,0xCE,0x7A,0xC1,0xAE,0x83,0x3E,0x5A,0xAA,0x89,0x83,0x57,0xAC,0x25,0x01,0x76,0x0C,
		0xAD,0xAE,0x8E,0x2C,0x37,0xCE,0xEB,0x35,0x78,0x64,0x54,0x03,0xE5,0x84,0x40,0x51,0xC9,0xBF,0x8F,0x08,0xE2,0x8A,0x82,0x08,0xD2,0x16,0x86,0x37,0x55,0xE9,0xB1,0x21,0x02,0xAD,0x76,0x68,0x81,0x9A,0x05,0xA2,0x4B,0xC9,0x4B,0x25,0x66,0x22,0x56,0x6C,0x88,0x07,0x8F,0xF7,0x81,0x59,0x6D,0x84,0x07,0x65,0x70,0x13,0x71,0x76,0x3E,0x9B,0x77,0x4C,0xE3,0x50,0x89,0x56,0x98,0x48,0xB9,0x1D,0xA7,0x29,0x1A,0x13,0x2E,0x4A,0x11,0x59,0x9C,0x1E,0x15,0xD5,0x49,0x54,0x2C,0x73,0x3A,0x69,0x82,0xB1,0x97,0x39,0x9C,0x6D,0x70,0x67,
		0x48,0xE5,0xDD,0x2D,0xD6,0xC8,0x1E,0x7B,0x02,0x03,0x01,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x03,0x7E,0x00,0x88,0xD1,0xD1,0x79,0x21,0xCE,0xE2,0x8B,0xE8,0xF8,0xC1,0x7D,0x34,0x53,0x3F,0x61,0x83,0xD9,0xB6,0x0B,0x38,0x17,0xB6,0xE8,0xBE,0x21,0x8D,0x8F,0x00,0xB8,0x8B,0x53,0x7E,0x44,0x67,0x1E,0x22,0xBD,0x97,0x27,0xE0,0x9C,0x85,0xCC,0x4A,0xF6,0x85,0x3B,0xB2,0xE2,0xBE,0x92,0xD3,0xE5,0x0D,0xE9,0xAF,0x5C,0x0E,0x0C,0x46,0x95,0xFF,0xA1,0x1C,0x5E,0x3E,0xE8,0x36,
		0x58,0x7A,0x73,0xA6,0x0A,0xF8,0x22,0x11,0x6B,0xC3,0x09,0x38,0x7E,0x26,0xBB,0x73,0xEF,0x00,0xBD,0x02,0xA4,0xF3,0x14,0x0D,0x30,0x3F,0x61,0x70,0x7B,0x20,0xFE,0x32,0xA3,0x9F,0xB3,0xF4,0x67,0x52,0xDC,0xB4,0xEE,0x84,0x8C,0x96,0x36,0x20,0xDE,0x81,0x08,0x83,0x71,0x21,0x8A,0x0F,0x9E,0xA9 };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assert.IsTrue (x509.Equals (clone), "Equals");
	Assert.IsTrue (clone.Equals (x509), "Equals");

	FileStream fs = File.OpenWrite (temp_certificate_filename);
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile (temp_certificate_filename);
	Assert.IsTrue (disk.Equals (clone), "Equals");
	Assert.IsTrue (disk.Equals (x509), "Equals");
	byte[] hash = { 0x0D,0x97,0x44,0x61,0x70,0x37,0x13,0xCB,0x74,0x93,0x2D,0x2A,0x75,0xAC,0xBC,0x71,0x4B,0x28,0x12,0x66 };
	Assert.AreEqual (hash, x509.GetCertHash (), "GetCertHash");
	Assert.AreEqual ("0D974461703713CB74932D2A75ACBC714B281266", x509.GetCertHashString (), "GetCertHashString");
#if NET_2_0
	DateTime from = DateTime.ParseExact (x509.GetEffectiveDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("11/09/1994 23:54:17", from.ToString (), "GetEffectiveDateString");
	DateTime until = DateTime.ParseExact (x509.GetExpirationDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("12/31/1999 23:54:17", until.ToString (), "GetExpirationDateString");
	Assert.AreEqual ("0241000001", x509.GetSerialNumberString (), "GetSerialNumberString");
#else
	// fx 1.x has a bug where the returned dates were always in the Seattle time zone
	Assert.AreEqual ("11/09/1994 15:54:17", x509.GetEffectiveDateString (), "GetEffectiveDateString");
	Assert.AreEqual ("12/31/1999 15:54:17", x509.GetExpirationDateString (), "GetExpirationDateString");
	// which was making it easier to test the dates ;-)
	Assert.AreEqual ("0100004102", x509.GetSerialNumberString (), "GetSerialNumberString");
#endif
	Assert.AreEqual ("X509", x509.GetFormat (), "GetFormat");
	Assert.AreEqual (228017249, x509.GetHashCode (), "GetHashCode");
	Assert.AreEqual ("C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetIssuerName (), "GetIssuerName");
	Assert.AreEqual ("1.2.840.113549.1.1.1", x509.GetKeyAlgorithm (), "GetKeyAlgorithm");
	byte[] keyparams = { 0x05,0x00 };
	Assert.AreEqual (keyparams, x509.GetKeyAlgorithmParameters (), "GetKeyAlgorithmParameters");
	Assert.AreEqual ("0500", x509.GetKeyAlgorithmParametersString (), "GetKeyAlgorithmParametersString");
	Assert.AreEqual ("C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetName (), "GetName");
	byte[] pubkey = { 0x30,0x81,0x85,0x02,0x7E,0x00,0x92,0xCE,0x7A,0xC1,0xAE,0x83,0x3E,0x5A,0xAA,0x89,0x83,0x57,0xAC,0x25,0x01,0x76,0x0C,0xAD,0xAE,0x8E,0x2C,0x37,0xCE,0xEB,0x35,0x78,0x64,0x54,0x03,0xE5,0x84,0x40,0x51,0xC9,0xBF,0x8F,0x08,0xE2,0x8A,0x82,0x08,0xD2,0x16,0x86,0x37,0x55,0xE9,0xB1,0x21,0x02,0xAD,0x76,0x68,0x81,0x9A,0x05,0xA2,0x4B,0xC9,0x4B,0x25,0x66,0x22,0x56,0x6C,0x88,0x07,0x8F,0xF7,0x81,0x59,0x6D,0x84,0x07,0x65,0x70,0x13,0x71,0x76,0x3E,0x9B,0x77,0x4C,0xE3,0x50,0x89,0x56,0x98,0x48,0xB9,0x1D,0xA7,0x29,0x1A,0x13,
		0x2E,0x4A,0x11,0x59,0x9C,0x1E,0x15,0xD5,0x49,0x54,0x2C,0x73,0x3A,0x69,0x82,0xB1,0x97,0x39,0x9C,0x6D,0x70,0x67,0x48,0xE5,0xDD,0x2D,0xD6,0xC8,0x1E,0x7B,0x02,0x03,0x01,0x00,0x01 };
	Assert.AreEqual (pubkey, x509.GetPublicKey (), "GetPublicKey");
	Assert.AreEqual ("308185027E0092CE7AC1AE833E5AAA898357AC2501760CADAE8E2C37CEEB3578645403E5844051C9BF8F08E28A8208D216863755E9B12102AD7668819A05A24BC94B256622566C88078FF781596D840765701371763E9B774CE35089569848B91DA7291A132E4A11599C1E15D549542C733A6982B197399C6D706748E5DD2DD6C81E7B0203010001", x509.GetPublicKeyString (), "GetPublicKeyString");
	Assert.AreEqual (cert, x509.GetRawCertData (), "GetRawCertData");
	Assert.AreEqual (ToString (cert), x509.GetRawCertDataString (), "GetRawCertDataString");
	byte[] serial = { 0x01,0x00,0x00,0x41,0x02 };
	Assert.AreEqual (serial, x509.GetSerialNumber (), "GetSerialNumber");
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x22,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x22,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,
		0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x22,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x22,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,
		0x69,0x74,0x79,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,0x20,0x30,0x31,0x30,0x30,0x30,0x30,0x34,0x31,0x30,0x32,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,
		0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x38,0x31,0x38,0x35,0x30,0x32,0x37,0x45,0x30,0x30,0x39,0x32,0x43,0x45,0x37,0x41,0x43,0x31,0x41,0x45,0x38,0x33,0x33,0x45,0x35,0x41,0x41,0x41,0x38,0x39,0x38,0x33,0x35,0x37,0x41,0x43,0x32,0x35,0x30,0x31,0x37,0x36,0x30,0x43,0x41,0x44,0x41,0x45,0x38,0x45,0x32,0x43,0x33,0x37,0x43,0x45,0x45,0x42,0x33,0x35,0x37,0x38,0x36,0x34,0x35,0x34,0x30,0x33,0x45,0x35,0x38,0x34,0x34,0x30,0x35,0x31,0x43,
		0x39,0x42,0x46,0x38,0x46,0x30,0x38,0x45,0x32,0x38,0x41,0x38,0x32,0x30,0x38,0x44,0x32,0x31,0x36,0x38,0x36,0x33,0x37,0x35,0x35,0x45,0x39,0x42,0x31,0x32,0x31,0x30,0x32,0x41,0x44,0x37,0x36,0x36,0x38,0x38,0x31,0x39,0x41,0x30,0x35,0x41,0x32,0x34,0x42,0x43,0x39,0x34,0x42,0x32,0x35,0x36,0x36,0x32,0x32,0x35,0x36,0x36,0x43,0x38,0x38,0x30,0x37,0x38,0x46,0x46,0x37,0x38,0x31,0x35,0x39,0x36,0x44,0x38,0x34,0x30,0x37,0x36,0x35,0x37,0x30,0x31,0x33,0x37,0x31,0x37,0x36,0x33,0x45,0x39,0x42,0x37,0x37,0x34,0x43,0x45,
		0x33,0x35,0x30,0x38,0x39,0x35,0x36,0x39,0x38,0x34,0x38,0x42,0x39,0x31,0x44,0x41,0x37,0x32,0x39,0x31,0x41,0x31,0x33,0x32,0x45,0x34,0x41,0x31,0x31,0x35,0x39,0x39,0x43,0x31,0x45,0x31,0x35,0x44,0x35,0x34,0x39,0x35,0x34,0x32,0x43,0x37,0x33,0x33,0x41,0x36,0x39,0x38,0x32,0x42,0x31,0x39,0x37,0x33,0x39,0x39,0x43,0x36,0x44,0x37,0x30,0x36,0x37,0x34,0x38,0x45,0x35,0x44,0x44,0x32,0x44,0x44,0x36,0x43,0x38,0x31,0x45,0x37,0x42,0x30,0x32,0x30,0x33,0x30,0x31,0x30,0x30,0x30,0x31,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assert.AreEqual (tsa, x509.ToString (true), "ToString(true)");
#if NET_2_0
	Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x509.Issuer, "Issuer");
	Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x509.Subject, "Subject");
#endif
}
开发者ID:nlhepler,项目名称:mono,代码行数:68,代码来源:X509CertificateTest.cs

示例11: Certificate13

public void Certificate13 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x02,0x14,0x30,0x82,0x01,0xD3,0xA0,0x03,0x02,0x01,0x02,0x02,0x01,0x02,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x30,0x3A,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x0A,0x13,0x11,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x73,0x31,0x0F,0x30,0x0D,0x06,0x03,0x55,0x04,0x03,0x13,0x06,0x44,0x53,0x41,0x20,0x43,0x41,0x30,0x1E,0x17,0x0D,0x30,0x31,0x30,0x34,0x31,0x39,0x31,0x34,0x35,0x37,
		0x32,0x30,0x5A,0x17,0x0D,0x31,0x31,0x30,0x34,0x31,0x39,0x31,0x34,0x35,0x37,0x32,0x30,0x5A,0x30,0x4F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x1A,0x30,0x18,0x06,0x03,0x55,0x04,0x0A,0x13,0x11,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x73,0x31,0x24,0x30,0x22,0x06,0x03,0x55,0x04,0x03,0x13,0x1B,0x44,0x53,0x41,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x20,0x49,0x6E,0x68,0x65,0x72,0x69,0x74,0x65,0x64,0x20,0x43,0x41,0x30,
		0x81,0x92,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x01,0x03,0x81,0x84,0x00,0x02,0x81,0x80,0x67,0x8C,0x47,0xDA,0x0C,0x36,0x81,0x64,0x39,0xF8,0x1A,0x37,0x0B,0xF0,0xBB,0xD4,0x13,0xFD,0x67,0x3D,0x40,0xC8,0x9C,0x92,0xE1,0x3A,0x89,0x54,0xB0,0xF2,0x97,0xA5,0x70,0xD0,0x64,0x17,0xA4,0xA7,0x7C,0xA9,0xE9,0x27,0x09,0x65,0xDF,0xA0,0xA5,0x1C,0xFC,0x04,0xDA,0x3E,0xDD,0x62,0x6B,0xF0,0x0C,0xED,0x81,0x57,0x4F,0x5D,0x29,0xC8,0x08,0x59,0x19,0x0C,0x5F,0x8D,0x88,0xF0,0xFF,0x8C,0xB6,0xE8,0x75,0x01,0xBE,0x10,
		0x0A,0x64,0xDF,0x57,0x7B,0x8B,0x6C,0x56,0xF0,0x53,0xCE,0x43,0x88,0xB9,0x09,0x99,0x08,0x3C,0x90,0xAF,0x01,0xE8,0xD9,0x32,0x5D,0xED,0x56,0x02,0xCF,0x60,0xD2,0x01,0x3A,0xE3,0x0A,0x2B,0x9E,0x91,0x41,0xF6,0xC7,0x7C,0xDE,0x6C,0x99,0x63,0x00,0x0E,0xA3,0x7C,0x30,0x7A,0x30,0x1D,0x06,0x03,0x55,0x1D,0x0E,0x04,0x16,0x04,0x14,0x5D,0x24,0xEE,0x8A,0x55,0x1A,0xF2,0xC6,0xC9,0xB2,0xC2,0xBF,0x8A,0xF0,0xB2,0x49,0x4F,0x3A,0xB3,0x1B,0x30,0x1F,0x06,0x03,0x55,0x1D,0x23,0x04,0x18,0x30,0x16,0x80,0x14,0x74,0x15,0xD5,0x24,
		0x1C,0xBD,0x5E,0x65,0x88,0x1F,0xE1,0x8B,0x09,0x7E,0x7F,0xEA,0x19,0x48,0x4E,0x61,0x30,0x17,0x06,0x03,0x55,0x1D,0x20,0x04,0x10,0x30,0x0E,0x30,0x0C,0x06,0x0A,0x60,0x86,0x48,0x01,0x65,0x03,0x02,0x01,0x30,0x01,0x30,0x0E,0x06,0x03,0x55,0x1D,0x0F,0x01,0x01,0xFF,0x04,0x04,0x03,0x02,0x01,0x06,0x30,0x0F,0x06,0x03,0x55,0x1D,0x13,0x01,0x01,0xFF,0x04,0x05,0x30,0x03,0x01,0x01,0xFF,0x30,0x09,0x06,0x07,0x2A,0x86,0x48,0xCE,0x38,0x04,0x03,0x03,0x30,0x00,0x30,0x2D,0x02,0x15,0x00,0xA8,0x59,0x6F,0x31,0x77,0xB6,0x20,
		0xEC,0x36,0x9B,0xEB,0x4B,0x61,0x0A,0xAF,0x44,0xED,0x72,0xBA,0x29,0x02,0x14,0x6D,0x22,0xE1,0xBD,0x4D,0x27,0xF6,0x2E,0x3B,0x1F,0xD7,0x9D,0xD6,0x59,0x5E,0xCB,0x25,0x86,0x22,0xD8 };

	X509Certificate x509 = new X509Certificate (cert);
//	X509Certificate clone = new X509Certificate (x509);

//	Assert.IsTrue (x509.Equals (clone), "Equals");
//	Assert.IsTrue (clone.Equals (x509), "Equals");

	FileStream fs = File.OpenWrite ("temp.cer");
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile ("temp.cer");
//	Assert.IsTrue (disk.Equals (clone), "Equals");
	Assert.IsTrue (disk.Equals (x509), "Equals");
	byte[] hash = { 0x0E,0x29,0xCD,0xDC,0xA5,0xE7,0x32,0xA2,0x0D,0xCE,0xD8,0x7B,0x3D,0x00,0x24,0x46,0x85,0x3E,0xBB,0xD1 };
	Assert.AreEqual (hash, x509.GetCertHash (), "GetCertHash");
	Assert.AreEqual ("0E29CDDCA5E732A20DCED87B3D002446853EBBD1", x509.GetCertHashString (), "GetCertHashString");
#if NET_2_0
	DateTime from = DateTime.ParseExact (x509.GetEffectiveDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("04/19/2001 14:57:20", from.ToString (), "GetEffectiveDateString");
	DateTime until = DateTime.ParseExact (x509.GetExpirationDateString (), "MM/dd/yyyy HH:mm:ss", null).ToUniversalTime ();
	Assert.AreEqual ("04/19/2011 14:57:20", until.ToString (), "GetExpirationDateString");
#else
	// fx 1.x has a bug where the returned dates were always in the Seattle time zone
	Assert.AreEqual (DateTime.Parse ("04/19/2001 06:57:20"), DateTime.Parse (x509.GetEffectiveDateString ()), "GetEffectiveDateString");
	Assert.AreEqual (DateTime.Parse ("04/19/2011 06:57:20"), DateTime.Parse (x509.GetExpirationDateString ()), "GetExpirationDateString");
	// which was making it easier to test the dates ;-)
#endif
	Assert.AreEqual ("X509", x509.GetFormat (), "GetFormat");
	Assert.AreEqual (237620700, x509.GetHashCode (), "GetHashCode");
	Assert.AreEqual ("C=US, O=Test Certificates, CN=DSA CA", x509.GetIssuerName (), "GetIssuerName");
	Assert.AreEqual ("1.2.840.10040.4.1", x509.GetKeyAlgorithm (), "GetKeyAlgorithm");
	// this fails under 2.0
	Assert.IsNull (x509.GetKeyAlgorithmParameters (), "GetKeyAlgorithmParameters");
	Assert.IsNull (x509.GetKeyAlgorithmParametersString (), "GetKeyAlgorithmParametersString");
	Assert.AreEqual ("C=US, O=Test Certificates, CN=DSA Parameters Inherited CA", x509.GetName (), "GetName");
	byte[] pubkey = { 0x02,0x81,0x80,0x67,0x8C,0x47,0xDA,0x0C,0x36,0x81,0x64,0x39,0xF8,0x1A,0x37,0x0B,0xF0,0xBB,0xD4,0x13,0xFD,0x67,0x3D,0x40,0xC8,0x9C,0x92,0xE1,0x3A,0x89,0x54,0xB0,0xF2,0x97,0xA5,0x70,0xD0,0x64,0x17,0xA4,0xA7,0x7C,0xA9,0xE9,0x27,0x09,0x65,0xDF,0xA0,0xA5,0x1C,0xFC,0x04,0xDA,0x3E,0xDD,0x62,0x6B,0xF0,0x0C,0xED,0x81,0x57,0x4F,0x5D,0x29,0xC8,0x08,0x59,0x19,0x0C,0x5F,0x8D,0x88,0xF0,0xFF,0x8C,0xB6,0xE8,0x75,0x01,0xBE,0x10,0x0A,0x64,0xDF,0x57,0x7B,0x8B,0x6C,0x56,0xF0,0x53,0xCE,0x43,0x88,0xB9,0x09,0x99,0x08,0x3C,
		0x90,0xAF,0x01,0xE8,0xD9,0x32,0x5D,0xED,0x56,0x02,0xCF,0x60,0xD2,0x01,0x3A,0xE3,0x0A,0x2B,0x9E,0x91,0x41,0xF6,0xC7,0x7C,0xDE,0x6C,0x99,0x63,0x00,0x0E };
	Assert.AreEqual (pubkey, x509.GetPublicKey (), "GetPublicKey");
	Assert.AreEqual ("028180678C47DA0C36816439F81A370BF0BBD413FD673D40C89C92E13A8954B0F297A570D06417A4A77CA9E9270965DFA0A51CFC04DA3EDD626BF00CED81574F5D29C80859190C5F8D88F0FF8CB6E87501BE100A64DF577B8B6C56F053CE4388B90999083C90AF01E8D9325DED5602CF60D2013AE30A2B9E9141F6C77CDE6C9963000E", x509.GetPublicKeyString (), "GetPublicKeyString");
	Assert.AreEqual (cert, x509.GetRawCertData (), "GetRawCertData");
	Assert.AreEqual (ToString (cert), x509.GetRawCertDataString (), "GetRawCertDataString");
	byte[] serial = { 0x02 };
	Assert.AreEqual (serial, x509.GetSerialNumber (), "GetSerialNumber");
	Assert.AreEqual ("02", x509.GetSerialNumberString (), "GetSerialNumberString");
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x73,0x2C,0x20,0x43,0x4E,0x3D,0x44,0x53,0x41,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x20,0x49,0x6E,0x68,0x65,0x72,0x69,0x74,0x65,0x64,0x20,0x43,0x41,0x0D,0x0A,0x09,0x49,0x73,0x73,
		0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x54,0x65,0x73,0x74,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x65,0x73,0x2C,0x20,0x43,0x4E,0x3D,0x44,0x53,0x41,0x20,0x43,0x41,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x30,0x30,0x34,0x30,0x2E,0x34,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,
		0x20,0x30,0x32,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x30,0x32,0x38,0x31,0x38,0x30,0x36,0x37,0x38,0x43,0x34,0x37,0x44,0x41,0x30,0x43,0x33,0x36,0x38,0x31,0x36,0x34,0x33,0x39,0x46,0x38,0x31,0x41,0x33,0x37,0x30,0x42,0x46,0x30,0x42,0x42,0x44,0x34,0x31,0x33,0x46,0x44,0x36,0x37,0x33,0x44,0x34,0x30,0x43,0x38,0x39,0x43,0x39,0x32,0x45,0x31,0x33,0x41,0x38,0x39,0x35,0x34,0x42,0x30,0x46,0x32,0x39,0x37,0x41,0x35,0x37,0x30,0x44,0x30,0x36,0x34,0x31,0x37,0x41,0x34,0x41,
		0x37,0x37,0x43,0x41,0x39,0x45,0x39,0x32,0x37,0x30,0x39,0x36,0x35,0x44,0x46,0x41,0x30,0x41,0x35,0x31,0x43,0x46,0x43,0x30,0x34,0x44,0x41,0x33,0x45,0x44,0x44,0x36,0x32,0x36,0x42,0x46,0x30,0x30,0x43,0x45,0x44,0x38,0x31,0x35,0x37,0x34,0x46,0x35,0x44,0x32,0x39,0x43,0x38,0x30,0x38,0x35,0x39,0x31,0x39,0x30,0x43,0x35,0x46,0x38,0x44,0x38,0x38,0x46,0x30,0x46,0x46,0x38,0x43,0x42,0x36,0x45,0x38,0x37,0x35,0x30,0x31,0x42,0x45,0x31,0x30,0x30,0x41,0x36,0x34,0x44,0x46,0x35,0x37,0x37,0x42,0x38,0x42,0x36,0x43,0x35,
		0x36,0x46,0x30,0x35,0x33,0x43,0x45,0x34,0x33,0x38,0x38,0x42,0x39,0x30,0x39,0x39,0x39,0x30,0x38,0x33,0x43,0x39,0x30,0x41,0x46,0x30,0x31,0x45,0x38,0x44,0x39,0x33,0x32,0x35,0x44,0x45,0x44,0x35,0x36,0x30,0x32,0x43,0x46,0x36,0x30,0x44,0x32,0x30,0x31,0x33,0x41,0x45,0x33,0x30,0x41,0x32,0x42,0x39,0x45,0x39,0x31,0x34,0x31,0x46,0x36,0x43,0x37,0x37,0x43,0x44,0x45,0x36,0x43,0x39,0x39,0x36,0x33,0x30,0x30,0x30,0x45,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assert.AreEqual (tsa, x509.ToString (true), "ToString(true)");
#if NET_2_0
	Assert.AreEqual ("C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.Issuer, "Issuer");
	Assert.AreEqual ("C=US, S=California, O=CommerceNet, OU=Server Certification Authority", x509.Subject, "Subject");
#endif
}
开发者ID:carrie901,项目名称:mono,代码行数:66,代码来源:X509CertificateTest.cs

示例12: Certificate1

public void Certificate1 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x01,0xFF,0x30,0x82,0x01,0x6C,0x02,0x05,0x02,0x72,0x00,0x06,0xE8,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
		0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x37,0x5A,0x17,0x0D,0x39,0x37,0x30,0x33,0x31,0x32,0x31,0x38,0x33,0x38,0x34,0x36,0x5A,0x30,0x61,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x13,0x30,0x11,0x06,0x03,0x55,0x04,0x08,0x13,0x0A,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x31,0x14,0x30,0x12,0x06,0x03,
		0x55,0x04,0x0A,0x13,0x0B,0x43,0x6F,0x6D,0x6D,0x65,0x72,0x63,0x65,0x4E,0x65,0x74,0x31,0x27,0x30,0x25,0x06,0x03,0x55,0x04,0x0B,0x13,0x1E,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x70,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x5F,0x00,0x30,0x5C,0x02,0x55,0x2D,0x58,0xE9,0xBF,0xF0,0x31,0xCD,0x79,0x06,0x50,0x5A,0xD5,0x9E,0x0E,0x2C,0xE6,0xC2,0xF7,0xF9,
		0xD2,0xCE,0x55,0x64,0x85,0xB1,0x90,0x9A,0x92,0xB3,0x36,0xC1,0xBC,0xEA,0xC8,0x23,0xB7,0xAB,0x3A,0xA7,0x64,0x63,0x77,0x5F,0x84,0x22,0x8E,0xE5,0xB6,0x45,0xDD,0x46,0xAE,0x0A,0xDD,0x00,0xC2,0x1F,0xBA,0xD9,0xAD,0xC0,0x75,0x62,0xF8,0x95,0x82,0xA2,0x80,0xB1,0x82,0x69,0xFA,0xE1,0xAF,0x7F,0xBC,0x7D,0xE2,0x7C,0x76,0xD5,0xBC,0x2A,0x80,0xFB,0x02,0x03,0x01,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x03,0x7E,0x00,0x54,0x20,0x67,0x12,0xBB,0x66,0x14,0xC3,0x26,0x6B,0x7F,
		0xDA,0x4A,0x25,0x4D,0x8B,0xE0,0xFD,0x1E,0x53,0x6D,0xAC,0xA2,0xD0,0x89,0xB8,0x2E,0x90,0xA0,0x27,0x43,0xA4,0xEE,0x4A,0x26,0x86,0x40,0xFF,0xB8,0x72,0x8D,0x1E,0xE7,0xB7,0x77,0xDC,0x7D,0xD8,0x3F,0x3A,0x6E,0x55,0x10,0xA6,0x1D,0xB5,0x58,0xF2,0xF9,0x0F,0x2E,0xB4,0x10,0x55,0x48,0xDC,0x13,0x5F,0x0D,0x08,0x26,0x88,0xC9,0xAF,0x66,0xF2,0x2C,0x9C,0x6F,0x3D,0xC3,0x2B,0x69,0x28,0x89,0x40,0x6F,0x8F,0x35,0x3B,0x9E,0xF6,0x8E,0xF1,0x11,0x17,0xFB,0x0C,0x98,0x95,0xA1,0xC2,0xBA,0x89,0x48,0xEB,0xB4,0x06,0x6A,0x22,0x54,
		0xD7,0xBA,0x18,0x3A,0x48,0xA6,0xCB,0xC2,0xFD,0x20,0x57,0xBC,0x63,0x1C };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assertion.Assert ("Equals", x509.Equals (clone));
	Assertion.Assert ("Equals", clone.Equals (x509));

	FileStream fs = File.OpenWrite ("temp.cer");
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile ("temp.cer");
	Assertion.Assert ("Equals", disk.Equals (clone));
	Assertion.Assert ("Equals", disk.Equals (x509));
	byte[] hash = { 0xD6,0x2F,0x48,0xD0,0x13,0xEE,0x7F,0xB5,0x8B,0x79,0x07,0x45,0x12,0x67,0x0D,0x9C,0x5B,0x3A,0x5D,0xA9 };
	AssertEquals ("GetCertHash", hash, x509.GetCertHash ());
	Assertion.AssertEquals ("GetCertHashString", "D62F48D013EE7FB58B79074512670D9C5B3A5DA9", x509.GetCertHashString ());
	Assertion.AssertEquals ("GetEffectiveDateString", "03/12/1996 10:38:47", x509.GetEffectiveDateString ());
	Assertion.AssertEquals ("GetExpirationDateString", "03/12/1997 10:38:46", x509.GetExpirationDateString ());
	Assertion.AssertEquals ("GetFormat", "X509", x509.GetFormat ());
	Assertion.AssertEquals ("GetHashCode", -701544240, x509.GetHashCode ());
	Assertion.AssertEquals ("GetIssuerName", "C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetIssuerName ());
	Assertion.AssertEquals ("GetKeyAlgorithm", "1.2.840.113549.1.1.1", x509.GetKeyAlgorithm ());
	byte[] keyparams = { 0x05,0x00 };
	AssertEquals ("GetKeyAlgorithmParameters", keyparams, x509.GetKeyAlgorithmParameters ());
	Assertion.AssertEquals ("GetKeyAlgorithmParametersString", "0500", x509.GetKeyAlgorithmParametersString ());
	Assertion.AssertEquals ("GetName", "C=US, S=California, O=CommerceNet, OU=Server Certification Authority", x509.GetName ());
	byte[] pubkey = { 0x30,0x5C,0x02,0x55,0x2D,0x58,0xE9,0xBF,0xF0,0x31,0xCD,0x79,0x06,0x50,0x5A,0xD5,0x9E,0x0E,0x2C,0xE6,0xC2,0xF7,0xF9,0xD2,0xCE,0x55,0x64,0x85,0xB1,0x90,0x9A,0x92,0xB3,0x36,0xC1,0xBC,0xEA,0xC8,0x23,0xB7,0xAB,0x3A,0xA7,0x64,0x63,0x77,0x5F,0x84,0x22,0x8E,0xE5,0xB6,0x45,0xDD,0x46,0xAE,0x0A,0xDD,0x00,0xC2,0x1F,0xBA,0xD9,0xAD,0xC0,0x75,0x62,0xF8,0x95,0x82,0xA2,0x80,0xB1,0x82,0x69,0xFA,0xE1,0xAF,0x7F,0xBC,0x7D,0xE2,0x7C,0x76,0xD5,0xBC,0x2A,0x80,0xFB,0x02,0x03,0x01,0x00,0x01 };
	AssertEquals ("GetPublicKey", pubkey, x509.GetPublicKey ());
	Assertion.AssertEquals ("GetPublicKeyString", "305C02552D58E9BFF031CD7906505AD59E0E2CE6C2F7F9D2CE556485B1909A92B336C1BCEAC823B7AB3AA76463775F84228EE5B645DD46AE0ADD00C21FBAD9ADC07562F89582A280B18269FAE1AF7FBC7DE27C76D5BC2A80FB0203010001", x509.GetPublicKeyString ());
	AssertEquals ("GetRawCertData", cert, x509.GetRawCertData ());
	Assertion.AssertEquals ("GetRawCertDataString", ToString (cert), x509.GetRawCertDataString ());
	byte[] serial = { 0xE8,0x06,0x00,0x72,0x02 };
	AssertEquals ("GetSerialNumber", serial, x509.GetSerialNumber ());
	Assertion.AssertEquals ("GetSerialNumberString", "E806007202", x509.GetSerialNumberString ());
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x53,0x3D,0x43,0x61,0x6C,0x69,0x66,0x6F,0x72,0x6E,0x69,0x61,0x2C,0x20,0x4F,0x3D,0x43,0x6F,0x6D,0x6D,0x65,0x72,0x63,0x65,0x4E,0x65,0x74,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,
		0x6F,0x72,0x69,0x74,0x79,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x22,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x22,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x0D,0x0A,0x09,0x4B,
		0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,0x20,0x45,0x38,0x30,0x36,0x30,0x30,0x37,0x32,0x30,0x32,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,
		0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x35,0x43,0x30,0x32,0x35,0x35,0x32,0x44,0x35,0x38,0x45,0x39,0x42,0x46,0x46,0x30,0x33,0x31,0x43,0x44,0x37,0x39,0x30,0x36,0x35,0x30,0x35,0x41,0x44,0x35,0x39,0x45,0x30,0x45,0x32,0x43,0x45,0x36,0x43,0x32,0x46,0x37,0x46,0x39,0x44,0x32,0x43,0x45,0x35,0x35,0x36,0x34,0x38,0x35,0x42,0x31,0x39,0x30,0x39,0x41,0x39,0x32,0x42,0x33,0x33,0x36,0x43,0x31,0x42,0x43,0x45,0x41,0x43,0x38,0x32,0x33,0x42,0x37,0x41,0x42,0x33,0x41,0x41,0x37,
		0x36,0x34,0x36,0x33,0x37,0x37,0x35,0x46,0x38,0x34,0x32,0x32,0x38,0x45,0x45,0x35,0x42,0x36,0x34,0x35,0x44,0x44,0x34,0x36,0x41,0x45,0x30,0x41,0x44,0x44,0x30,0x30,0x43,0x32,0x31,0x46,0x42,0x41,0x44,0x39,0x41,0x44,0x43,0x30,0x37,0x35,0x36,0x32,0x46,0x38,0x39,0x35,0x38,0x32,0x41,0x32,0x38,0x30,0x42,0x31,0x38,0x32,0x36,0x39,0x46,0x41,0x45,0x31,0x41,0x46,0x37,0x46,0x42,0x43,0x37,0x44,0x45,0x32,0x37,0x43,0x37,0x36,0x44,0x35,0x42,0x43,0x32,0x41,0x38,0x30,0x46,0x42,0x30,0x32,0x30,0x33,0x30,0x31,0x30,0x30,
		0x30,0x31,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assertion.AssertEquals ("ToString(true)", tsa, x509.ToString (true));
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:53,代码来源:X509CertificateTest.cs

示例13: Certificate6

public void Certificate6 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x01,0xDF,0x30,0x82,0x01,0x48,0x02,0x01,0x00,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x30,0x39,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0D,0x30,0x0B,0x06,0x03,0x55,0x04,0x0A,0x14,0x04,0x41,0x54,0x26,0x54,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x0B,0x14,0x12,0x44,0x69,0x72,0x65,0x63,0x74,0x6F,0x72,0x79,0x20,0x53,0x65,0x72,0x76,0x69,0x63,0x65,0x73,0x30,0x1E,0x17,0x0D,0x39,0x36,0x30,0x31,0x31,0x38,0x32,0x31,0x30,0x33,0x35,0x32,
		0x5A,0x17,0x0D,0x30,0x31,0x30,0x31,0x31,0x36,0x32,0x31,0x30,0x33,0x35,0x32,0x5A,0x30,0x39,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x0D,0x30,0x0B,0x06,0x03,0x55,0x04,0x0A,0x14,0x04,0x41,0x54,0x26,0x54,0x31,0x1B,0x30,0x19,0x06,0x03,0x55,0x04,0x0B,0x14,0x12,0x44,0x69,0x72,0x65,0x63,0x74,0x6F,0x72,0x79,0x20,0x53,0x65,0x72,0x76,0x69,0x63,0x65,0x73,0x30,0x81,0x9D,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x8B,0x00,0x30,0x81,0x87,
		0x02,0x81,0x81,0x00,0x87,0x64,0x72,0x89,0x0B,0x20,0x8F,0x87,0x27,0xAC,0xC6,0x22,0xFE,0x00,0x40,0x69,0x48,0xAF,0xC6,0x86,0xCD,0x23,0x33,0xE3,0x11,0xC5,0x31,0x1A,0x1F,0x7E,0x9E,0x92,0x13,0xB6,0xA2,0xAC,0xE3,0xB0,0x1F,0x2A,0x07,0x6C,0xB6,0xD4,0xDE,0x4B,0xFA,0xF1,0xA2,0xA0,0x7D,0xCE,0x4B,0xBE,0xBE,0x26,0x48,0x09,0x8C,0x85,0x11,0xDE,0xCB,0x22,0xE7,0xC2,0xEE,0x44,0x51,0xFE,0x67,0xD5,0x5B,0x5A,0xE0,0x16,0x37,0x54,0x04,0xB8,0x3B,0x32,0x12,0x94,0x83,0x9E,0xB1,0x4D,0x80,0x6C,0xA4,0xA9,0x76,0xAC,0xB8,0xA4,
		0x97,0xF7,0xAB,0x0B,0x6C,0xA5,0x43,0xBA,0x6E,0x4F,0xC5,0x4E,0x00,0x30,0x16,0x3C,0x3F,0x99,0x14,0xDA,0xA2,0x20,0x08,0x8B,0xBA,0xED,0x76,0xAC,0x97,0x00,0xD5,0x6D,0x02,0x01,0x0F,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x04,0x05,0x00,0x03,0x81,0x81,0x00,0x38,0x50,0x1D,0x0A,0xD3,0x1B,0xBB,0xA2,0x9F,0x6C,0x8D,0x10,0xAA,0x42,0x1B,0x05,0x8D,0xE4,0x25,0xAB,0xFB,0x55,0xAE,0x6D,0xBA,0x53,0x67,0x15,0x07,0x9A,0xEC,0x55,0x9F,0x72,0x89,0x5F,0x24,0xB0,0xDB,0xCA,0x64,0xBD,0x64,0xAA,0xC2,0x8C,
		0xD9,0x3D,0xA2,0x45,0xB7,0xC6,0x92,0x71,0x51,0xEF,0xED,0xE1,0x51,0x54,0x97,0x56,0x35,0xA1,0xCE,0xE4,0x44,0xC4,0x47,0x66,0xFF,0x91,0xDA,0x88,0x9C,0x23,0xC2,0xB3,0xD4,0x62,0x4A,0xBC,0x94,0x55,0x9C,0x80,0x8E,0xB3,0xDD,0x4F,0x1A,0xED,0x12,0x5A,0xB5,0x2E,0xBC,0xF8,0x4B,0xCE,0xC6,0xD4,0x70,0xB3,0xB3,0x22,0xF8,0x5E,0x5C,0x36,0x7A,0xA6,0xB8,0x39,0x73,0x46,0x43,0x5C,0x9B,0x9A,0xBD,0x1E,0x7E,0xA7,0x04,0xCF,0x25,0x35 };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assertion.Assert ("Equals", x509.Equals (clone));
	Assertion.Assert ("Equals", clone.Equals (x509));

	FileStream fs = File.OpenWrite ("temp.cer");
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile ("temp.cer");
	Assertion.Assert ("Equals", disk.Equals (clone));
	Assertion.Assert ("Equals", disk.Equals (x509));
	byte[] hash = { 0x95,0xD4,0xE2,0xEA,0x34,0x0B,0xBF,0x33,0x27,0x1C,0x1F,0xBA,0x8B,0x52,0x9F,0x17,0x72,0x1F,0x8A,0x99 };
	AssertEquals ("GetCertHash", hash, x509.GetCertHash ());
	Assertion.AssertEquals ("GetCertHashString", "95D4E2EA340BBF33271C1FBA8B529F17721F8A99", x509.GetCertHashString ());
	Assertion.AssertEquals ("GetEffectiveDateString", "01/18/1996 13:03:52", x509.GetEffectiveDateString ());
	Assertion.AssertEquals ("GetExpirationDateString", "01/16/2001 13:03:52", x509.GetExpirationDateString ());
	Assertion.AssertEquals ("GetFormat", "X509", x509.GetFormat ());
	Assertion.AssertEquals ("GetHashCode", -1781210390, x509.GetHashCode ());
	Assertion.AssertEquals ("GetIssuerName", "C=US, O=AT&T, OU=Directory Services", x509.GetIssuerName ());
	Assertion.AssertEquals ("GetKeyAlgorithm", "1.2.840.113549.1.1.1", x509.GetKeyAlgorithm ());
	byte[] keyparams = { 0x05,0x00 };
	AssertEquals ("GetKeyAlgorithmParameters", keyparams, x509.GetKeyAlgorithmParameters ());
	Assertion.AssertEquals ("GetKeyAlgorithmParametersString", "0500", x509.GetKeyAlgorithmParametersString ());
	Assertion.AssertEquals ("GetName", "C=US, O=AT&T, OU=Directory Services", x509.GetName ());
	byte[] pubkey = { 0x30,0x81,0x87,0x02,0x81,0x81,0x00,0x87,0x64,0x72,0x89,0x0B,0x20,0x8F,0x87,0x27,0xAC,0xC6,0x22,0xFE,0x00,0x40,0x69,0x48,0xAF,0xC6,0x86,0xCD,0x23,0x33,0xE3,0x11,0xC5,0x31,0x1A,0x1F,0x7E,0x9E,0x92,0x13,0xB6,0xA2,0xAC,0xE3,0xB0,0x1F,0x2A,0x07,0x6C,0xB6,0xD4,0xDE,0x4B,0xFA,0xF1,0xA2,0xA0,0x7D,0xCE,0x4B,0xBE,0xBE,0x26,0x48,0x09,0x8C,0x85,0x11,0xDE,0xCB,0x22,0xE7,0xC2,0xEE,0x44,0x51,0xFE,0x67,0xD5,0x5B,0x5A,0xE0,0x16,0x37,0x54,0x04,0xB8,0x3B,0x32,0x12,0x94,0x83,0x9E,0xB1,0x4D,0x80,0x6C,0xA4,0xA9,0x76,0xAC,
		0xB8,0xA4,0x97,0xF7,0xAB,0x0B,0x6C,0xA5,0x43,0xBA,0x6E,0x4F,0xC5,0x4E,0x00,0x30,0x16,0x3C,0x3F,0x99,0x14,0xDA,0xA2,0x20,0x08,0x8B,0xBA,0xED,0x76,0xAC,0x97,0x00,0xD5,0x6D,0x02,0x01,0x0F };
	AssertEquals ("GetPublicKey", pubkey, x509.GetPublicKey ());
	Assertion.AssertEquals ("GetPublicKeyString", "30818702818100876472890B208F8727ACC622FE00406948AFC686CD2333E311C5311A1F7E9E9213B6A2ACE3B01F2A076CB6D4DE4BFAF1A2A07DCE4BBEBE2648098C8511DECB22E7C2EE4451FE67D55B5AE016375404B83B321294839EB14D806CA4A976ACB8A497F7AB0B6CA543BA6E4FC54E0030163C3F9914DAA220088BBAED76AC9700D56D02010F", x509.GetPublicKeyString ());
	AssertEquals ("GetRawCertData", cert, x509.GetRawCertData ());
	Assertion.AssertEquals ("GetRawCertDataString", ToString (cert), x509.GetRawCertDataString ());
	byte[] serial = { 0x00 };
	AssertEquals ("GetSerialNumber", serial, x509.GetSerialNumber ());
	Assertion.AssertEquals ("GetSerialNumberString", "00", x509.GetSerialNumberString ());
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x41,0x54,0x26,0x54,0x2C,0x20,0x4F,0x55,0x3D,0x44,0x69,0x72,0x65,0x63,0x74,0x6F,0x72,0x79,0x20,0x53,0x65,0x72,0x76,0x69,0x63,0x65,0x73,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x41,0x54,0x26,0x54,
		0x2C,0x20,0x4F,0x55,0x3D,0x44,0x69,0x72,0x65,0x63,0x74,0x6F,0x72,0x79,0x20,0x53,0x65,0x72,0x76,0x69,0x63,0x65,0x73,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,0x20,0x30,0x30,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,
		0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x38,0x31,0x38,0x37,0x30,0x32,0x38,0x31,0x38,0x31,0x30,0x30,0x38,0x37,0x36,0x34,0x37,0x32,0x38,0x39,0x30,0x42,0x32,0x30,0x38,0x46,0x38,0x37,0x32,0x37,0x41,0x43,0x43,0x36,0x32,0x32,0x46,0x45,0x30,0x30,0x34,0x30,0x36,0x39,0x34,0x38,0x41,0x46,0x43,0x36,0x38,0x36,0x43,0x44,0x32,0x33,0x33,0x33,0x45,0x33,0x31,0x31,0x43,0x35,0x33,
		0x31,0x31,0x41,0x31,0x46,0x37,0x45,0x39,0x45,0x39,0x32,0x31,0x33,0x42,0x36,0x41,0x32,0x41,0x43,0x45,0x33,0x42,0x30,0x31,0x46,0x32,0x41,0x30,0x37,0x36,0x43,0x42,0x36,0x44,0x34,0x44,0x45,0x34,0x42,0x46,0x41,0x46,0x31,0x41,0x32,0x41,0x30,0x37,0x44,0x43,0x45,0x34,0x42,0x42,0x45,0x42,0x45,0x32,0x36,0x34,0x38,0x30,0x39,0x38,0x43,0x38,0x35,0x31,0x31,0x44,0x45,0x43,0x42,0x32,0x32,0x45,0x37,0x43,0x32,0x45,0x45,0x34,0x34,0x35,0x31,0x46,0x45,0x36,0x37,0x44,0x35,0x35,0x42,0x35,0x41,0x45,0x30,0x31,0x36,0x33,
		0x37,0x35,0x34,0x30,0x34,0x42,0x38,0x33,0x42,0x33,0x32,0x31,0x32,0x39,0x34,0x38,0x33,0x39,0x45,0x42,0x31,0x34,0x44,0x38,0x30,0x36,0x43,0x41,0x34,0x41,0x39,0x37,0x36,0x41,0x43,0x42,0x38,0x41,0x34,0x39,0x37,0x46,0x37,0x41,0x42,0x30,0x42,0x36,0x43,0x41,0x35,0x34,0x33,0x42,0x41,0x36,0x45,0x34,0x46,0x43,0x35,0x34,0x45,0x30,0x30,0x33,0x30,0x31,0x36,0x33,0x43,0x33,0x46,0x39,0x39,0x31,0x34,0x44,0x41,0x41,0x32,0x32,0x30,0x30,0x38,0x38,0x42,0x42,0x41,0x45,0x44,0x37,0x36,0x41,0x43,0x39,0x37,0x30,0x30,0x44,
		0x35,0x36,0x44,0x30,0x32,0x30,0x31,0x30,0x46,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assertion.AssertEquals ("ToString(true)", tsa, x509.ToString (true));
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:53,代码来源:X509CertificateTest.cs

示例14: Certificate4

public void Certificate4 ()
{
	// certificate can be loaded by constructor
	byte[] cert = { 0x30,0x82,0x02,0x29,0x30,0x82,0x01,0x96,0x02,0x05,0x02,0x41,0x00,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,
		0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x1E,0x17,0x0D,0x39,0x34,0x31,0x31,0x30,0x39,0x32,0x33,0x35,0x34,0x31,0x37,0x5A,0x17,0x0D,0x39,0x39,0x31,0x32,0x33,0x31,0x32,0x33,0x35,0x34,0x31,0x37,0x5A,0x30,0x5F,0x31,0x0B,0x30,0x09,0x06,0x03,0x55,0x04,0x06,0x13,0x02,0x55,0x53,0x31,0x20,0x30,0x1E,0x06,0x03,0x55,0x04,0x0A,0x13,0x17,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,
		0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x31,0x2E,0x30,0x2C,0x06,0x03,0x55,0x04,0x0B,0x13,0x25,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x30,0x81,0x9B,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x01,0x05,0x00,0x03,0x81,0x89,0x00,0x30,0x81,0x85,0x02,0x7E,0x00,0x92,0xCE,0x7A,0xC1,0xAE,0x83,0x3E,0x5A,0xAA,0x89,0x83,0x57,0xAC,0x25,0x01,0x76,0x0C,
		0xAD,0xAE,0x8E,0x2C,0x37,0xCE,0xEB,0x35,0x78,0x64,0x54,0x03,0xE5,0x84,0x40,0x51,0xC9,0xBF,0x8F,0x08,0xE2,0x8A,0x82,0x08,0xD2,0x16,0x86,0x37,0x55,0xE9,0xB1,0x21,0x02,0xAD,0x76,0x68,0x81,0x9A,0x05,0xA2,0x4B,0xC9,0x4B,0x25,0x66,0x22,0x56,0x6C,0x88,0x07,0x8F,0xF7,0x81,0x59,0x6D,0x84,0x07,0x65,0x70,0x13,0x71,0x76,0x3E,0x9B,0x77,0x4C,0xE3,0x50,0x89,0x56,0x98,0x48,0xB9,0x1D,0xA7,0x29,0x1A,0x13,0x2E,0x4A,0x11,0x59,0x9C,0x1E,0x15,0xD5,0x49,0x54,0x2C,0x73,0x3A,0x69,0x82,0xB1,0x97,0x39,0x9C,0x6D,0x70,0x67,
		0x48,0xE5,0xDD,0x2D,0xD6,0xC8,0x1E,0x7B,0x02,0x03,0x01,0x00,0x01,0x30,0x0D,0x06,0x09,0x2A,0x86,0x48,0x86,0xF7,0x0D,0x01,0x01,0x02,0x05,0x00,0x03,0x7E,0x00,0x88,0xD1,0xD1,0x79,0x21,0xCE,0xE2,0x8B,0xE8,0xF8,0xC1,0x7D,0x34,0x53,0x3F,0x61,0x83,0xD9,0xB6,0x0B,0x38,0x17,0xB6,0xE8,0xBE,0x21,0x8D,0x8F,0x00,0xB8,0x8B,0x53,0x7E,0x44,0x67,0x1E,0x22,0xBD,0x97,0x27,0xE0,0x9C,0x85,0xCC,0x4A,0xF6,0x85,0x3B,0xB2,0xE2,0xBE,0x92,0xD3,0xE5,0x0D,0xE9,0xAF,0x5C,0x0E,0x0C,0x46,0x95,0xFF,0xA1,0x1C,0x5E,0x3E,0xE8,0x36,
		0x58,0x7A,0x73,0xA6,0x0A,0xF8,0x22,0x11,0x6B,0xC3,0x09,0x38,0x7E,0x26,0xBB,0x73,0xEF,0x00,0xBD,0x02,0xA4,0xF3,0x14,0x0D,0x30,0x3F,0x61,0x70,0x7B,0x20,0xFE,0x32,0xA3,0x9F,0xB3,0xF4,0x67,0x52,0xDC,0xB4,0xEE,0x84,0x8C,0x96,0x36,0x20,0xDE,0x81,0x08,0x83,0x71,0x21,0x8A,0x0F,0x9E,0xA9 };

	X509Certificate x509 = new X509Certificate (cert);
	X509Certificate clone = new X509Certificate (x509);

	Assertion.Assert ("Equals", x509.Equals (clone));
	Assertion.Assert ("Equals", clone.Equals (x509));

	FileStream fs = File.OpenWrite ("temp.cer");
	fs.Write (cert, 0, cert.Length);
	fs.Close ();

	X509Certificate disk = X509Certificate.CreateFromCertFile ("temp.cer");
	Assertion.Assert ("Equals", disk.Equals (clone));
	Assertion.Assert ("Equals", disk.Equals (x509));
	byte[] hash = { 0x0D,0x97,0x44,0x61,0x70,0x37,0x13,0xCB,0x74,0x93,0x2D,0x2A,0x75,0xAC,0xBC,0x71,0x4B,0x28,0x12,0x66 };
	AssertEquals ("GetCertHash", hash, x509.GetCertHash ());
	Assertion.AssertEquals ("GetCertHashString", "0D974461703713CB74932D2A75ACBC714B281266", x509.GetCertHashString ());
	Assertion.AssertEquals ("GetEffectiveDateString", "11/09/1994 15:54:17", x509.GetEffectiveDateString ());
	Assertion.AssertEquals ("GetExpirationDateString", "12/31/1999 15:54:17", x509.GetExpirationDateString ());
	Assertion.AssertEquals ("GetFormat", "X509", x509.GetFormat ());
	Assertion.AssertEquals ("GetHashCode", 228017249, x509.GetHashCode ());
	Assertion.AssertEquals ("GetIssuerName", "C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetIssuerName ());
	Assertion.AssertEquals ("GetKeyAlgorithm", "1.2.840.113549.1.1.1", x509.GetKeyAlgorithm ());
	byte[] keyparams = { 0x05,0x00 };
	AssertEquals ("GetKeyAlgorithmParameters", keyparams, x509.GetKeyAlgorithmParameters ());
	Assertion.AssertEquals ("GetKeyAlgorithmParametersString", "0500", x509.GetKeyAlgorithmParametersString ());
	Assertion.AssertEquals ("GetName", "C=US, O=\"RSA Data Security, Inc.\", OU=Secure Server Certification Authority", x509.GetName ());
	byte[] pubkey = { 0x30,0x81,0x85,0x02,0x7E,0x00,0x92,0xCE,0x7A,0xC1,0xAE,0x83,0x3E,0x5A,0xAA,0x89,0x83,0x57,0xAC,0x25,0x01,0x76,0x0C,0xAD,0xAE,0x8E,0x2C,0x37,0xCE,0xEB,0x35,0x78,0x64,0x54,0x03,0xE5,0x84,0x40,0x51,0xC9,0xBF,0x8F,0x08,0xE2,0x8A,0x82,0x08,0xD2,0x16,0x86,0x37,0x55,0xE9,0xB1,0x21,0x02,0xAD,0x76,0x68,0x81,0x9A,0x05,0xA2,0x4B,0xC9,0x4B,0x25,0x66,0x22,0x56,0x6C,0x88,0x07,0x8F,0xF7,0x81,0x59,0x6D,0x84,0x07,0x65,0x70,0x13,0x71,0x76,0x3E,0x9B,0x77,0x4C,0xE3,0x50,0x89,0x56,0x98,0x48,0xB9,0x1D,0xA7,0x29,0x1A,0x13,
		0x2E,0x4A,0x11,0x59,0x9C,0x1E,0x15,0xD5,0x49,0x54,0x2C,0x73,0x3A,0x69,0x82,0xB1,0x97,0x39,0x9C,0x6D,0x70,0x67,0x48,0xE5,0xDD,0x2D,0xD6,0xC8,0x1E,0x7B,0x02,0x03,0x01,0x00,0x01 };
	AssertEquals ("GetPublicKey", pubkey, x509.GetPublicKey ());
	Assertion.AssertEquals ("GetPublicKeyString", "308185027E0092CE7AC1AE833E5AAA898357AC2501760CADAE8E2C37CEEB3578645403E5844051C9BF8F08E28A8208D216863755E9B12102AD7668819A05A24BC94B256622566C88078FF781596D840765701371763E9B774CE35089569848B91DA7291A132E4A11599C1E15D549542C733A6982B197399C6D706748E5DD2DD6C81E7B0203010001", x509.GetPublicKeyString ());
	AssertEquals ("GetRawCertData", cert, x509.GetRawCertData ());
	Assertion.AssertEquals ("GetRawCertDataString", ToString (cert), x509.GetRawCertDataString ());
	byte[] serial = { 0x01,0x00,0x00,0x41,0x02 };
	AssertEquals ("GetSerialNumber", serial, x509.GetSerialNumber ());
	Assertion.AssertEquals ("GetSerialNumberString", "0100004102", x509.GetSerialNumberString ());
	byte[] ToStringArray = { 0x43,0x45,0x52,0x54,0x49,0x46,0x49,0x43,0x41,0x54,0x45,0x3A,0x0D,0x0A,0x09,0x46,0x6F,0x72,0x6D,0x61,0x74,0x3A,0x20,0x20,0x58,0x35,0x30,0x39,0x0D,0x0A,0x09,0x4E,0x61,0x6D,0x65,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x22,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x22,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,
		0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,0x69,0x74,0x79,0x0D,0x0A,0x09,0x49,0x73,0x73,0x75,0x69,0x6E,0x67,0x20,0x43,0x41,0x3A,0x20,0x20,0x43,0x3D,0x55,0x53,0x2C,0x20,0x4F,0x3D,0x22,0x52,0x53,0x41,0x20,0x44,0x61,0x74,0x61,0x20,0x53,0x65,0x63,0x75,0x72,0x69,0x74,0x79,0x2C,0x20,0x49,0x6E,0x63,0x2E,0x22,0x2C,0x20,0x4F,0x55,0x3D,0x53,0x65,0x63,0x75,0x72,0x65,0x20,0x53,0x65,0x72,0x76,0x65,0x72,0x20,0x43,0x65,0x72,0x74,0x69,0x66,0x69,0x63,0x61,0x74,0x69,0x6F,0x6E,0x20,0x41,0x75,0x74,0x68,0x6F,0x72,
		0x69,0x74,0x79,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x67,0x6F,0x72,0x69,0x74,0x68,0x6D,0x3A,0x20,0x20,0x31,0x2E,0x32,0x2E,0x38,0x34,0x30,0x2E,0x31,0x31,0x33,0x35,0x34,0x39,0x2E,0x31,0x2E,0x31,0x2E,0x31,0x0D,0x0A,0x09,0x53,0x65,0x72,0x69,0x61,0x6C,0x20,0x4E,0x75,0x6D,0x62,0x65,0x72,0x3A,0x20,0x20,0x30,0x31,0x30,0x30,0x30,0x30,0x34,0x31,0x30,0x32,0x0D,0x0A,0x09,0x4B,0x65,0x79,0x20,0x41,0x6C,0x6F,0x67,0x72,0x69,0x74,0x68,0x6D,0x20,0x50,0x61,0x72,0x61,0x6D,0x65,0x74,0x65,0x72,0x73,0x3A,0x20,
		0x20,0x30,0x35,0x30,0x30,0x0D,0x0A,0x09,0x50,0x75,0x62,0x6C,0x69,0x63,0x20,0x4B,0x65,0x79,0x3A,0x20,0x20,0x33,0x30,0x38,0x31,0x38,0x35,0x30,0x32,0x37,0x45,0x30,0x30,0x39,0x32,0x43,0x45,0x37,0x41,0x43,0x31,0x41,0x45,0x38,0x33,0x33,0x45,0x35,0x41,0x41,0x41,0x38,0x39,0x38,0x33,0x35,0x37,0x41,0x43,0x32,0x35,0x30,0x31,0x37,0x36,0x30,0x43,0x41,0x44,0x41,0x45,0x38,0x45,0x32,0x43,0x33,0x37,0x43,0x45,0x45,0x42,0x33,0x35,0x37,0x38,0x36,0x34,0x35,0x34,0x30,0x33,0x45,0x35,0x38,0x34,0x34,0x30,0x35,0x31,0x43,
		0x39,0x42,0x46,0x38,0x46,0x30,0x38,0x45,0x32,0x38,0x41,0x38,0x32,0x30,0x38,0x44,0x32,0x31,0x36,0x38,0x36,0x33,0x37,0x35,0x35,0x45,0x39,0x42,0x31,0x32,0x31,0x30,0x32,0x41,0x44,0x37,0x36,0x36,0x38,0x38,0x31,0x39,0x41,0x30,0x35,0x41,0x32,0x34,0x42,0x43,0x39,0x34,0x42,0x32,0x35,0x36,0x36,0x32,0x32,0x35,0x36,0x36,0x43,0x38,0x38,0x30,0x37,0x38,0x46,0x46,0x37,0x38,0x31,0x35,0x39,0x36,0x44,0x38,0x34,0x30,0x37,0x36,0x35,0x37,0x30,0x31,0x33,0x37,0x31,0x37,0x36,0x33,0x45,0x39,0x42,0x37,0x37,0x34,0x43,0x45,
		0x33,0x35,0x30,0x38,0x39,0x35,0x36,0x39,0x38,0x34,0x38,0x42,0x39,0x31,0x44,0x41,0x37,0x32,0x39,0x31,0x41,0x31,0x33,0x32,0x45,0x34,0x41,0x31,0x31,0x35,0x39,0x39,0x43,0x31,0x45,0x31,0x35,0x44,0x35,0x34,0x39,0x35,0x34,0x32,0x43,0x37,0x33,0x33,0x41,0x36,0x39,0x38,0x32,0x42,0x31,0x39,0x37,0x33,0x39,0x39,0x43,0x36,0x44,0x37,0x30,0x36,0x37,0x34,0x38,0x45,0x35,0x44,0x44,0x32,0x44,0x44,0x36,0x43,0x38,0x31,0x45,0x37,0x42,0x30,0x32,0x30,0x33,0x30,0x31,0x30,0x30,0x30,0x31,0x0D,0x0A,0x0D,0x0A };
	string tsa = Encoding.Default.GetString (ToStringArray).Replace ("\r\n", Environment.NewLine);
	//Assertion.AssertEquals ("ToString(true)", tsa, x509.ToString (true));
}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:54,代码来源:X509CertificateTest.cs

示例15: CheckBase64

		private void CheckBase64 (X509Certificate x)
		{
			// note: the raw data is still the DER encoded ASN.1 (not the base64 string)
			byte[] cert = { 0x30, 0x82, 0x01, 0xC5, 0x30, 0x82, 0x01, 0x32, 0xA0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x10, 0xC7, 0x75, 0xAE, 0x48, 0x53, 0x9B, 0x1E, 0x9E, 0x44, 0x80, 0x15, 0xCA, 0x78, 0x15, 0x47, 0x69, 0x30, 0x09, 
				0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x30, 0x25, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x1E, 0x1A, 0x00, 0x43, 0x00, 0x41, 0x00, 0x53, 0x00, 0x54, 0x00, 0x4F, 0x00, 0x52, 
				0x00, 0x5C, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x75, 0x30, 0x1E, 0x17, 0x0D, 0x30, 0x35, 0x30, 0x36, 0x30, 0x38, 0x31, 0x33, 0x33, 0x38, 0x34, 0x37, 0x5A, 0x17, 0x0D, 0x30, 
				0x36, 0x30, 0x36, 0x30, 0x38, 0x31, 0x39, 0x33, 0x38, 0x34, 0x37, 0x5A, 0x30, 0x25, 0x31, 0x23, 0x30, 0x21, 0x06, 0x03, 0x55, 0x04, 0x03, 0x1E, 0x1A, 0x00, 0x43, 0x00, 0x41, 0x00, 0x53, 0x00, 0x54, 0x00, 
				0x4F, 0x00, 0x52, 0x00, 0x5C, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x75, 0x00, 0x70, 0x00, 0x6F, 0x00, 0x75, 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 
				0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xDA, 0xEA, 0x39, 0x38, 0xF6, 0x3A, 0xF4, 0x8B, 0xF9, 0xE2, 0xC7, 0xD5, 0x2C, 0xF9, 0x1A, 0xD5, 0x75, 0xCF, 0x17, 0xAC, 0xB3, 0x46, 
				0xBD, 0x7F, 0x3F, 0x97, 0x38, 0x2E, 0x10, 0x41, 0xB2, 0xC4, 0xD9, 0x14, 0x15, 0xD8, 0xE6, 0xF9, 0x11, 0x38, 0x80, 0x75, 0xE3, 0xD7, 0x1F, 0xC0, 0x86, 0xA7, 0x3E, 0x02, 0x11, 0x04, 0xE9, 0x57, 0xB5, 0xD8, 
				0x57, 0x65, 0x27, 0x7B, 0x8F, 0xBA, 0xB9, 0xEF, 0xA0, 0x8F, 0x15, 0x9C, 0xEC, 0x2F, 0x85, 0x63, 0x4E, 0x52, 0x6B, 0xA6, 0xE3, 0x33, 0xCA, 0x86, 0x22, 0xBA, 0xF9, 0x06, 0xE8, 0xEC, 0xCB, 0xA7, 0xA5, 0xA8, 
				0xE2, 0x3E, 0xC7, 0x21, 0x74, 0x4E, 0xC9, 0xE9, 0x05, 0x5F, 0xAE, 0x78, 0x12, 0x51, 0x2F, 0xFA, 0x6A, 0x8F, 0x7C, 0xB0, 0x64, 0x2A, 0xFB, 0xB7, 0xB2, 0x40, 0x91, 0x20, 0xE7, 0x32, 0x53, 0x3F, 0x58, 0xCA, 
				0x80, 0xA2, 0x41, 0xC5, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1D, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, 0x9D, 0x57, 0xB0, 0x25, 0x97, 0x81, 0x22, 0x3C, 0xC4, 0x61, 
				0x9D, 0xC9, 0xDB, 0xD8, 0xC7, 0xC1, 0xED, 0xFB, 0x1C, 0xDD, 0x35, 0x98, 0xD7, 0x40, 0x58, 0xA4, 0x43, 0x86, 0x54, 0xF9, 0x68, 0x96, 0x85, 0xB5, 0x91, 0xBC, 0xB7, 0x82, 0xB2, 0x7E, 0x7B, 0x58, 0xBD, 0x80, 
				0xCE, 0x34, 0x7E, 0x22, 0x87, 0x62, 0x31, 0xB5, 0x03, 0x16, 0xA0, 0x20, 0x17, 0x9D, 0xE7, 0x5D, 0xAA, 0x12, 0xF5, 0x92, 0xDF, 0x94, 0xE6, 0x69, 0xCD, 0xF6, 0xFC, 0x82, 0x9B, 0xDC, 0xD3, 0x30, 0x40, 0xB1, 
				0x71, 0x4F, 0x4A, 0x64, 0xCB, 0xDC, 0x14, 0xC8, 0xC1, 0x7F, 0x6F, 0x23, 0xCE, 0xDD, 0x19, 0x22, 0x4F, 0x24, 0x1E, 0x27, 0x18, 0x66, 0x88, 0x7A, 0x9A, 0x9A, 0x09, 0x37, 0x6D, 0x65, 0x15, 0xE8, 0x28, 0x5E, 
				0x82, 0xEB, 0x5B, 0x82, 0xE8, 0x8A, 0xAC, 0x8F, 0xC3, 0x6C, 0xEE, 0xF0, 0x3E, 0x20, 0xCB, 0xC7 };
			Assert.AreEqual ("CN=CASTOR\\poupou", x.Issuer, "Issuer");
			Assert.AreEqual ("CN=CASTOR\\poupou", x.GetIssuerName (), "GetIssuerName");
			Assert.AreEqual ("CN=CASTOR\\poupou", x.Subject, "Subject");
			Assert.AreEqual ("CN=CASTOR\\poupou", x.GetName (), "GetName");
			byte[] hash = { 0x1D, 0x53, 0xCC, 0x89, 0xD0, 0x9F, 0x11, 0x4A, 0x48, 0x7F, 0x7F, 0x52, 0x9E, 0xCB, 0xD1, 0x86, 0xA3, 0xD5, 0x85, 0x29 };
			Assert.AreEqual (hash, x.GetCertHash (), "GetCertHash");
			Assert.AreEqual ("1D53CC89D09F114A487F7F529ECBD186A3D58529", x.GetCertHashString (), "GetCertHashString");
			long from = DateTime.Parse (x.GetEffectiveDateString ()).ToUniversalTime ().Ticks;
			Assert.AreEqual (632538347270000000, from, "GetEffectiveDateString");
			long until = DateTime.Parse (x.GetExpirationDateString ()).ToUniversalTime ().Ticks;
			Assert.AreEqual (632853923270000000, until, "GetExpirationDateString");
			Assert.AreEqual ("X509", x.GetFormat (), "GetFormat");
			Assert.AreEqual (492031113, x.GetHashCode (), "GetHashCode");
			Assert.AreEqual ("1.2.840.113549.1.1.1", x.GetKeyAlgorithm (), "GetKeyAlgorithm");
			byte[] keyparams = { 0x05, 0x00 };
			Assert.AreEqual (keyparams, x.GetKeyAlgorithmParameters (), "GetKeyAlgorithmParameters");
			Assert.AreEqual ("0500", x.GetKeyAlgorithmParametersString (), "GetKeyAlgorithmParametersString");
			byte[] pubkey = { 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xDA, 0xEA, 0x39, 0x38, 0xF6, 0x3A, 0xF4, 0x8B, 0xF9, 0xE2, 0xC7, 0xD5, 0x2C, 0xF9, 0x1A, 0xD5, 0x75, 0xCF, 0x17, 0xAC, 0xB3, 0x46, 0xBD, 0x7F, 0x3F, 0x97, 0x38, 0x2E, 0x10, 0x41, 0xB2, 0xC4, 0xD9, 0x14, 0x15, 0xD8, 0xE6, 0xF9, 0x11, 0x38, 0x80, 0x75, 0xE3, 0xD7, 0x1F, 0xC0, 0x86, 
				0xA7, 0x3E, 0x02, 0x11, 0x04, 0xE9, 0x57, 0xB5, 0xD8, 0x57, 0x65, 0x27, 0x7B, 0x8F, 0xBA, 0xB9, 0xEF, 0xA0, 0x8F, 0x15, 0x9C, 0xEC, 0x2F, 0x85, 0x63, 0x4E, 0x52, 0x6B, 0xA6, 0xE3, 0x33, 0xCA, 0x86, 0x22, 0xBA, 0xF9, 0x06, 0xE8, 0xEC, 0xCB, 0xA7, 0xA5, 0xA8, 0xE2, 0x3E, 0xC7, 0x21, 0x74, 0x4E, 0xC9, 0xE9, 0x05, 0x5F, 0xAE, 0x78, 0x12, 
				0x51, 0x2F, 0xFA, 0x6A, 0x8F, 0x7C, 0xB0, 0x64, 0x2A, 0xFB, 0xB7, 0xB2, 0x40, 0x91, 0x20, 0xE7, 0x32, 0x53, 0x3F, 0x58, 0xCA, 0x80, 0xA2, 0x41, 0xC5, 0x02, 0x03, 0x01, 0x00, 0x01 };
			Assert.AreEqual (pubkey, x.GetPublicKey (), "GetPublicKey");
			Assert.AreEqual ("30818902818100DAEA3938F63AF48BF9E2C7D52CF91AD575CF17ACB346BD7F3F97382E1041B2C4D91415D8E6F911388075E3D71FC086A73E021104E957B5D85765277B8FBAB9EFA08F159CEC2F85634E526BA6E333CA8622BAF906E8ECCBA7A5A8E23EC721744EC9E9055FAE7812512FFA6A8F7CB0642AFBB7B2409120E732533F58CA80A241C50203010001", x.GetPublicKeyString (), "GetPublicKeyString");
			Assert.AreEqual (cert, x.GetRawCertData (), "GetRawCertData");
			byte[] serial = { 0x69, 0x47, 0x15, 0x78, 0xCA, 0x15, 0x80, 0x44, 0x9E, 0x1E, 0x9B, 0x53, 0x48, 0xAE, 0x75, 0xC7 };
			Assert.AreEqual (serial, x.GetSerialNumber (), "GetSerialNumber");
			Assert.AreEqual ("C775AE48539B1E9E448015CA78154769", x.GetSerialNumberString (), "GetSerialNumberString");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:44,代码来源:X509Cert20Test.cs


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