ToString() public method

public ToString ( ) : string
return string
        /// <summary>
        /// Gets the find value.
        /// </summary>
        /// <param name="findType">Type of the find.</param>
        /// <param name="value">The value.</param>
        /// <returns>The find value formated as string.</returns>
        public static string GetFindValue(X509FindType findType, X509Certificate2 value)
        {
            string findValue = null;

            switch (findType)
            {
                case X509FindType.FindBySubjectDistinguishedName:
                    findValue = GetSubjectDistinguishedName(value.SubjectName.Name);
                    break;
                case X509FindType.FindByThumbprint:
                    findValue = value.Thumbprint;
                    break;
                case X509FindType.FindBySubjectName:
                    findValue = value.SubjectName.Name;
                    break;
                case X509FindType.FindBySerialNumber:
                    findValue = value.SerialNumber;
                    break;
                default:
                    findValue = value.ToString(false);
                    break;
            }

            return findValue;
        }
Exemplo n.º 2
0
 private string RecuperarChavePublica(byte[] RawData)
 {
     try
     {
         System.Security.Cryptography.X509Certificates.X509Certificate2 certificado =
             new System.Security.Cryptography.X509Certificates.X509Certificate2(RawData);
         return(certificado.ToString());
     }
     catch
     {
         return("");
     }
 }
Exemplo n.º 3
0
		public void Empty_ToString ()
		{
			string expected = "System.Security.Cryptography.X509Certificates.X509Certificate2";
			X509Certificate2 x = new X509Certificate2 ();
			Assert.AreEqual (expected, x.ToString (), "ToString()");
			Assert.AreEqual (expected, x.ToString (true), "ToString(true)");
			Assert.AreEqual (expected, x.ToString (false), "ToString(false)");
		}
Exemplo n.º 4
0
        ///////////////////////////////////////////////////////////////////////
        ///
        /// <summary>
        /// Display detail information.
        /// </summary>
        ///
        static void DisplayDetail(string title, X509Certificate2 certificate, bool detached) {
            if (title != null) {
                Console.WriteLine(title);
            }

            Console.WriteLine("Performing " + (detached ? "detached" : "non-detached") + " signature using the following certificate...");
            Console.WriteLine(certificate.ToString(true));
        }
Exemplo n.º 5
0
        private X509Certificate2Collection LoadCertificates()
        {
            X509Certificate2Collection collection = new X509Certificate2Collection();

            if(!String.IsNullOrEmpty(this.clientCertFilename))
            {
                Tracer.Debug("Attempting to load Client Certificate from file := " + this.clientCertFilename);
                X509Certificate2 certificate = new X509Certificate2(this.clientCertFilename, this.clientCertPassword);
                Tracer.Debug("Loaded Client Certificate := " + certificate.ToString());

                collection.Add(certificate);
            }
            else
            {
                string name = String.IsNullOrEmpty(this.keyStoreName) ? StoreName.My.ToString() : this.keyStoreName;

                StoreLocation location = StoreLocation.CurrentUser;

                if(!String.IsNullOrEmpty(this.keyStoreLocation))
                {
                    if(String.Compare(this.keyStoreLocation, "CurrentUser", true) == 0)
                    {
                        location = StoreLocation.CurrentUser;
                    }
                    else if(String.Compare(this.keyStoreLocation, "LocalMachine", true) == 0)
                    {
                        location = StoreLocation.LocalMachine;
                    }
                    else
                    {
                        throw new NMSException("Invlalid StoreLocation given on URI");
                    }
                }

                X509Store store = new X509Store(name, location);
                store.Open(OpenFlags.ReadOnly);
                collection = store.Certificates;
                store.Close();
            }

            return collection;
        }
Exemplo n.º 6
0
 ///////////////////////////////////////////////////////////////////////
 /// <summary>
 /// Display the certificate to console or using the UI.
 /// </summary>
 static void DisplayCertificate(string title, X509Certificate2 certificate)
 {
     Log.Comment(title);
     if (Verbose.UI == verbose)
     {
         //X509Certificate2UI.DisplayCertificate(certificate);
     }
     else if (Verbose.Detail == verbose)
     {
         Log.Comment(certificate.ToString(true));
     }
     else
     {
         // Normal.
         Log.Comment(certificate.ToString(false));
     }
 }