Example #1
0
        public override void Write(CertificateDetails details)
        {
            var  enumerator = details.Pairs.GetEnumerator();
            bool hasMore    = enumerator.MoveNext();

            while (hasMore)
            {
                this.writer.Write(Wrapped(enumerator.Current.Value.ToString()));
                hasMore = enumerator.MoveNext();
                if (hasMore)
                {
                    this.writer.Write(separator);
                }
            }
            this.writer.WriteLine();
        }
Example #2
0
        public override void WriteHeader(CertificateDetails details)
        {
            var  enumerator = details.FieldNames.GetEnumerator();
            bool hasMore    = enumerator.MoveNext();

            while (hasMore)
            {
                this.writer.Write(Wrapped(enumerator.Current));
                hasMore = enumerator.MoveNext();
                if (hasMore)
                {
                    this.writer.Write(separator);
                }
            }
            this.writer.WriteLine();
        }
Example #3
0
        public override int Run(IEnumerable <string> parameters, ResultWriter resultWriter)
        {
            string startDirectory = Environment.CurrentDirectory;
            string pattern        = "*.cer";
            bool   isFirst        = true;

            foreach (var file in Directory.EnumerateFiles(startDirectory, pattern, SearchOption.AllDirectories))
            {
                var details = CertificateDetails.OpenFromFile(file);
                if (isFirst)
                {
                    isFirst = false;
                    resultWriter.WriteHeader(details);
                }
                resultWriter.Write(details);
            }
            return(0);
        }
Example #4
0
 public override int Run(IEnumerable <string> parameters, ResultWriter resultWriter)
 {
     try
     {
         if (!parameters.Any())
         {
             Console.WriteLine("Must at least specify a certificate file.");
             return(10);
         }
         var    fileAndPassword = parameters.ToArray();
         string file            = fileAndPassword[0];
         string password        = null;
         if (fileAndPassword.Length > 1)
         {
             password = fileAndPassword[1];
         }
         CertificateDetails details = null;
         if (password != null)
         {
             details = CertificateDetails.OpenFromFile(file, password);
         }
         else
         {
             try
             {
                 details = CertificateDetails.OpenFromFile(file);
             }
             catch (CryptographicException ex)
             {
                 Console.WriteLine(ex.Message);
                 Console.WriteLine("file seems to be a .pfx file with a private key, please also specify the password.");
                 return(1);
             }
         }
         resultWriter.WriteHeader(details);
         resultWriter.Write(details);
     }
     catch (FileNotFoundException ex)
     {
         Console.WriteLine(ex.Message);
         return(1);
     }
     return(0);
 }
Example #5
0
 public override void WriteHeader(CertificateDetails details)
 {
 }
Example #6
0
 public abstract void Write(CertificateDetails details);