// (c) 2006 Richard Grimes // www.grimes.demon.co.uk using System; using System.Security.Cryptography.X509Certificates; public class App { public static void Main(string[] args) { if (args.Length == 0) return; X509Certificate x509 = X509Certificate.CreateFromCertFile(args[0]); X509Certificate2 x509_2 = new X509Certificate2(x509); Console.WriteLine("X509 Version {0}", x509_2.Version); Console.WriteLine( "Issued to {0}\nIssued by {1}\nSerial# {2}\n" + "From {3} To {4}\nAlgo {5} Params {6}\n" + "Format {7}\n" + "Cert Hash\n{8}\nCert Data\n{9}\nPublic Key\n{10}", x509_2.Subject, x509_2.Issuer, x509_2.SerialNumber, x509_2.NotBefore.ToString(), x509_2.NotAfter.ToString(), x509_2.SignatureAlgorithm.Value, x509_2.PublicKey.EncodedParameters.Format(false), x509.GetFormat(), x509.GetCertHashString(), BitConverter.ToString(x509_2.RawData), x509_2.PublicKey.EncodedKeyValue.Format(false)); Console.WriteLine("Distiguished names:\nIssued to {0}\nIssued by {1}", x509_2.SubjectName.Name, x509_2.IssuerName.Name); Console.WriteLine("Thumbprint {0}", x509_2.Thumbprint); } }