2 using System.Security.Cryptography.X509Certificates;
\r
6 static int Main (string[] args)
\r
8 if (args.Length == 0) {
\r
9 Console.WriteLine ("Usage: mono x509build.exe filename");
\r
12 string filename = args [0];
\r
14 X509Certificate2 cert = new X509Certificate2 (filename);
\r
15 // using X509Chain.Create will use the X509Chain defined in machine.config
\r
16 X509Chain chain = X509Chain.Create ();
\r
17 bool result = chain.Build (cert);
\r
18 Console.WriteLine ("Build: {0}", result);
\r
19 Console.WriteLine ();
\r
21 Console.WriteLine ("ChainStatus:");
\r
22 if (chain.ChainStatus.Length > 0) {
\r
23 foreach (X509ChainStatus st in chain.ChainStatus) {
\r
24 Console.WriteLine ("\t{0}", st.Status);
\r
27 Console.WriteLine ("\t{0}", X509ChainStatusFlags.NoError);
\r
29 Console.WriteLine ();
\r
32 Console.WriteLine ("ChainElements:");
\r
33 foreach (X509ChainElement ce in chain.ChainElements) {
\r
34 Console.WriteLine ("{0}. Certificate: {1}", n++, ce.Certificate);
\r
35 Console.WriteLine ("\tChainStatus:");
\r
36 if (ce.ChainElementStatus.Length > 0) {
\r
37 foreach (X509ChainStatus st in ce.ChainElementStatus) {
\r
38 Console.WriteLine ("\t\t{0}", st.Status);
\r
41 Console.WriteLine ("\t\t{0}", X509ChainStatusFlags.NoError);
\r
43 Console.WriteLine ();
\r
46 return result ? 0 : 1;
\r