コード例 #1
0
        public void CanCheckPrivateKey()
        {
            DateTime  start = DateTime.Now;
            DateTime  end   = start + TimeSpan.FromMinutes(10);
            CryptoKey key   = new CryptoKey(new DSA(true));

            using (X509Certificate cert = new X509Certificate(101, "CN=localhost", "CN=Root", key, start, end)) {
                Assert.AreEqual(true, cert.CheckPrivateKey(key));

                CryptoKey other = new CryptoKey(new DSA(true));
                Assert.AreEqual(false, cert.CheckPrivateKey(other));
            }
        }
コード例 #2
0
		/// <summary>
		/// Constructs a X509CertifcateAuthority with the specified parameters.
		/// </summary>
		/// <param name="caCert"></param>
		/// <param name="caKey"></param>
		/// <param name="serial"></param>
		public X509CertificateAuthority(X509Certificate caCert, CryptoKey caKey, ISequenceNumber serial)
		{
			if (!caCert.CheckPrivateKey(caKey))
				throw new Exception("The specified CA Private Key does match the specified CA Certificate");

			this.caCert = caCert;
			this.caKey = caKey;
			this.serial = serial;
		}
コード例 #3
0
		public void CanCheckPrivateKey()
		{
			DateTime start = DateTime.Now;
			DateTime end = start + TimeSpan.FromMinutes(10);
			CryptoKey key = new CryptoKey(new DSA(true));
			using (X509Certificate cert = new X509Certificate(101, "CN=localhost", "CN=Root", key, start, end)) {
				Assert.AreEqual(true, cert.CheckPrivateKey(key));

				CryptoKey other = new CryptoKey(new DSA(true));
				Assert.AreEqual(false, cert.CheckPrivateKey(other));
			}
		}