本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.ToString方法的具体用法?C# X509Certificate2.ToString怎么用?C# X509Certificate2.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFindValue
/// <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;
}
示例2: Empty_ToString
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)");
}
示例3: DisplayDetail
///////////////////////////////////////////////////////////////////////
///
/// <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));
}
示例4: LoadCertificates
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;
}
示例5: DisplayCertificate
///////////////////////////////////////////////////////////////////////
/// <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));
}
}