Пример #1
0
        private X509KeyUsageExtension ValidateKeyUsage(X509KeyUsageFlags kuf, string rawdata)
        {
            X509KeyUsageExtension ku = new X509KeyUsageExtension(kuf, false);

            Assert.IsFalse(ku.Critical, kuf.ToString() + ".Critical");
            Assert.AreEqual(rawdata, BitConverter.ToString(ku.RawData), kuf.ToString() + ".RawData");
            Assert.AreEqual(oid, ku.Oid.Value, kuf.ToString() + ".Oid.Value");
            // FIXME: Don't expect that FriendlyName is English. This test fails under non-English Windows.
            //Assert.AreEqual (fname, ku.Oid.FriendlyName, kuf.ToString () + ".Oid.FriendlyName");
            Assert.AreEqual(kuf, ku.KeyUsages, kuf.ToString() + ".KeyUsages");
            return(ku);
        }
Пример #2
0
        private void listBoxCert_SelectedIndexChanged(object sender, EventArgs e)
        {
            X509Certificate2 c = (X509Certificate2)((ListBox)sender).SelectedItem;

            if (c == null)
            {
                return;
            }

            X509KeyUsageFlags keyFlags = X509KeyUsageFlags.None;
            String            crldist  = String.Empty;

            String certSerialNumber = c.GetSerialNumberString();

            tbCertName.Text  = certSerialNumber + " / " + HexToDecimal(certSerialNumber);
            tbCertName.Text += Environment.NewLine + c.GetExpirationDateString();
            foreach (X509Extension ext in c.Extensions)
            {
                String oid = ext.Oid.Value;
                // 2.5.29.15 Bruk av nøkler
                // 2.5.29.31 CRL-distib
                if (ext.Oid.Value == "2.5.29.15")
                {
                    X509KeyUsageExtension keyext = (X509KeyUsageExtension)ext;
                    keyFlags = keyext.KeyUsages;
                }
                else if (ext.Oid.Value == "2.5.29.31")
                {
                    crldist = ext.Format(true);
                }
            }

            tbCertName.Text += Environment.NewLine + "Key usage:" + keyFlags.ToString();

            tbCertName.Text += Environment.NewLine + crldist;

            //Form info = new formInfo("Bygger sertifikatkjede....");
            //info.Show();

            X509Chain chain = new X509Chain();

            chain.Build(c);
            //info.Close();
            //info.Dispose();
            int i = chain.ChainElements.Count;

            foreach (X509ChainElement che in chain.ChainElements)
            {
                tbCertName.Text += Environment.NewLine + "Chain:" + che.Certificate.Subject;
                //X509Certificate2UI.DisplayCertificate(che.Certificate);
            }
        }
		private X509KeyUsageExtension ValidateKeyUsage (X509KeyUsageFlags kuf, string rawdata)
		{
			X509KeyUsageExtension ku = new X509KeyUsageExtension (kuf, false);
			Assert.IsFalse (ku.Critical, kuf.ToString () + ".Critical");
			Assert.AreEqual (rawdata, BitConverter.ToString (ku.RawData), kuf.ToString () + ".RawData");
			Assert.AreEqual (oid, ku.Oid.Value, kuf.ToString () + ".Oid.Value");
			Assert.AreEqual (fname, ku.Oid.FriendlyName, kuf.ToString () + ".Oid.FriendlyName");
			Assert.AreEqual (kuf, ku.KeyUsages, kuf.ToString () + ".KeyUsages");
			return ku;
		}
Пример #4
0
		private X509KeyUsageExtension ValidateKeyUsage (X509KeyUsageFlags kuf, string rawdata)
		{
			X509KeyUsageExtension ku = new X509KeyUsageExtension (kuf, false);
			Assert.IsFalse (ku.Critical, kuf.ToString () + ".Critical");
			Assert.AreEqual (rawdata, BitConverter.ToString (ku.RawData), kuf.ToString () + ".RawData");
			Assert.AreEqual (oid, ku.Oid.Value, kuf.ToString () + ".Oid.Value");
			// FIXME: Don't expect that FriendlyName is English. This test fails under non-English Windows.
			//Assert.AreEqual (fname, ku.Oid.FriendlyName, kuf.ToString () + ".Oid.FriendlyName");
			Assert.AreEqual (kuf, ku.KeyUsages, kuf.ToString () + ".KeyUsages");
			return ku;
		}
 public static void TraceAndLog(string subject, string thumbPrint, X509KeyUsageFlags keyUsage)
 {
     DiagnosticUtility.EventLog.LogEvent(TraceEventType.Information, EventLogCategory.Wsat, (EventLogEventId)(-1073545195), new string[] { subject, thumbPrint, keyUsage.ToString() });
 }
 public static void TraceAndLog(string subject, string thumbPrint, X509KeyUsageFlags keyUsage)
 {
     DiagnosticUtility.EventLog.LogEvent(TraceEventType.Information, EventLogCategory.Wsat, (EventLogEventId) (-1073545195), new string[] { subject, thumbPrint, keyUsage.ToString() });
 }