本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate.CreateFromCertFile方法的具体用法?C# X509Certificate.CreateFromCertFile怎么用?C# X509Certificate.CreateFromCertFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate
的用法示例。
在下文中一共展示了X509Certificate.CreateFromCertFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Security.Cryptography.X509Certificates;
public class X509
{
public static void Main()
{
// The path to the certificate.
string Certificate = "Certificate.cer";
// Load the certificate into an X509Certificate object.
X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);
// Get the value.
string resultsTrue = cert.ToString(true);
// Display the value to the console.
Console.WriteLine(resultsTrue);
// Get the value.
string resultsFalse = cert.ToString(false);
// Display the value to the console.
Console.WriteLine(resultsFalse);
}
}
开发者ID:.NET开发者,项目名称:System.Security.Cryptography.X509Certificates,代码行数:29,代码来源:X509Certificate.CreateFromCertFile
示例2: Main
//引入命名空间
using System;
using System.Net;
using System.Security.Cryptography.X509Certificates;
class MainClass {
public static void Main() {
WebRequest requestA = WebRequest.Create("http://www.yoursite.com");
requestA.Credentials = new NetworkCredential("userName", "password");
requestA.PreAuthenticate = true;
WebRequest requestB = WebRequest.Create("http://www.yoursite.com");
requestB.Credentials = CredentialCache.DefaultCredentials;
requestB.PreAuthenticate = true;
HttpWebRequest requestC = (HttpWebRequest)WebRequest.Create("http://www.yoursite.com");
X509Certificate cert1 = X509Certificate.CreateFromCertFile("TestCertificate.cer");
requestC.ClientCertificates.Add(cert1);
HttpWebRequest requestD = (HttpWebRequest)WebRequest.Create("http://www.yoursite.com");
X509Store store = new X509Store();
X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySubjectName,"Joe", false);
if (certs.Count == 1) {
requestD.ClientCertificates.Add(certs[0]);
} else {
certs = X509Certificate2UI.SelectFromCollection(
store.Certificates,
"Select Certificate",
"Select the certificate to use for authentication.",
X509SelectionFlag.SingleSelection);
if (certs.Count != 0) {
requestD.ClientCertificates.Add(certs[0]);
}
}
}
}
开发者ID:C#程序员,项目名称:System.Security.Cryptography.X509Certificates,代码行数:36,代码来源:X509Certificate.CreateFromCertFile