本文整理汇总了C#中System.Security.Cryptography.X509Certificates.X509Certificate2.GetNameInfo方法的典型用法代码示例。如果您正苦于以下问题:C# X509Certificate2.GetNameInfo方法的具体用法?C# X509Certificate2.GetNameInfo怎么用?C# X509Certificate2.GetNameInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Security.Cryptography.X509Certificates.X509Certificate2
的用法示例。
在下文中一共展示了X509Certificate2.GetNameInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
Console.WriteLine("Starting...");
X509Certificate2 serverCertificate = new X509Certificate2("certificate.pfx"); // Any valid certificate with private key will work fine.
TcpListener listener = new TcpListener(IPAddress.Any, 4567);
TcpClient client = new TcpClient();
listener.Start();
Task clientConnectTask = client.ConnectAsync(IPAddress.Loopback, 4567);
Task<TcpClient> listenerAcceptTask = listener.AcceptTcpClientAsync();
Task.WaitAll(clientConnectTask, listenerAcceptTask);
TcpClient server = listenerAcceptTask.Result;
SslStream clientStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null, EncryptionPolicy.RequireEncryption);
SslStream serverStream = new SslStream(server.GetStream(), false, null, null, EncryptionPolicy.RequireEncryption);
Task clientAuthenticationTask = clientStream.AuthenticateAsClientAsync(serverCertificate.GetNameInfo(X509NameType.SimpleName, false), null, SslProtocols.Tls12, false);
Task serverAuthenticationTask = serverStream.AuthenticateAsServerAsync(serverCertificate, false, SslProtocols.Tls12, false);
Task.WaitAll(clientAuthenticationTask, serverAuthenticationTask);
byte[] readBuffer = new byte[256];
Task<int> readTask = clientStream.ReadAsync(readBuffer, 0, readBuffer.Length); // Create a pending ReadAsync, which will wait for data that will never come (for testing purposes).
byte[] writeBuffer = new byte[256];
Task writeTask = clientStream.WriteAsync(writeBuffer, 0, writeBuffer.Length); // The main thread actually blocks here (not asychronously waits) on .NET Core making this call.
bool result = Task.WaitAll(new Task[1] { writeTask }, 5000); // This code won't even be reached on .NET Core. Works fine on .NET Framework.
if (result)
{
Console.WriteLine("WriteAsync completed successfully while ReadAsync was pending... nothing locked up.");
}
else
{
Console.WriteLine("WriteAsync failed to complete after 5 seconds.");
}
}
示例2: find_certificate_name
static string find_certificate_name(X509Certificate2 cert)
{
string cert_name = cert.GetNameInfo(X509NameType.SimpleName, false);
if (cert_name.Count() == 0) {
cert_name = cert.GetNameInfo(X509NameType.DnsName, false);
}
if (cert_name.Count() == 0) {
cert_name = cert.GetNameInfo(X509NameType.DnsFromAlternativeName, false);
}
return cert_name;
}
示例3: DisplayIssuerName
public string DisplayIssuerName(X509Certificate2 cert)
{
string str = "";
if (cert == null)
{
return str;
}
return cert.GetNameInfo(X509NameType.SimpleName, true);
}
示例4: EchoServerAndClient
public async void EchoServerAndClient()
{
var testPromise = new TaskCompletionSource();
var tlsCertificate = new X509Certificate2("dotnetty.com.pfx", "password");
Func<Task> closeServerFunc = await this.StartServerAsync(true, ch =>
{
ch.Pipeline.AddLast("server logger", new LoggingHandler("SERVER"));
ch.Pipeline.AddLast("server tls", TlsHandler.Server(tlsCertificate));
ch.Pipeline.AddLast("server logger2", new LoggingHandler("SER***"));
ch.Pipeline.AddLast("server prepender", new LengthFieldPrepender(2));
ch.Pipeline.AddLast("server decoder", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
ch.Pipeline.AddLast(new EchoChannelHandler());
}, testPromise);
var group = new MultithreadEventLoopGroup();
Bootstrap b = new Bootstrap()
.Group(group)
.Channel<TcpSocketChannel>()
.Option(ChannelOption.TcpNodelay, true)
.Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
{
string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
var clientTlsSettings = new ClientTlsSettings(targetHost);
ch.Pipeline.AddLast("client logger", new LoggingHandler("CLIENT"));
ch.Pipeline.AddLast("client tls", new TlsHandler(stream => new SslStream(stream, true, (sender, certificate, chain, errors) => true), clientTlsSettings));
ch.Pipeline.AddLast("client logger2", new LoggingHandler("CLI***"));
ch.Pipeline.AddLast("client prepender", new LengthFieldPrepender(2));
ch.Pipeline.AddLast("client decoder", new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
ch.Pipeline.AddLast(new TestScenarioRunner(this.GetEchoClientScenario, testPromise));
}));
this.Output.WriteLine("Configured Bootstrap: {0}", b);
IChannel clientChannel = null;
try
{
clientChannel = await b.ConnectAsync(IPAddress.Loopback, Port);
this.Output.WriteLine("Connected channel: {0}", clientChannel);
await Task.WhenAny(testPromise.Task, Task.Delay(TimeSpan.FromSeconds(30)));
Assert.True(testPromise.Task.IsCompleted, "timed out");
testPromise.Task.Wait();
}
finally
{
Task serverCloseTask = closeServerFunc();
clientChannel?.CloseAsync().Wait(TimeSpan.FromSeconds(5));
group.ShutdownGracefullyAsync();
if (!serverCloseTask.Wait(ShutdownTimeout))
{
this.Output.WriteLine("Didn't stop in time.");
}
}
}
示例5: EchoServerAndClient
public async void EchoServerAndClient()
{
var testPromise = new TaskCompletionSource();
var tlsCertificate = new X509Certificate2("dotnetty.com.pfx", "password");
Func<Task> closeServerFunc = await this.StartServerAsync(true, ch =>
{
ch.Pipeline.AddLast(TlsHandler.Server(tlsCertificate));
ch.Pipeline.AddLast(new EchoChannelHandler());
}, testPromise);
var group = new MultithreadEventLoopGroup();
Bootstrap b = new Bootstrap()
.Group(group)
.Channel<TcpSocketChannel>()
.Option(ChannelOption.TcpNodelay, true)
.Handler(new ActionChannelInitializer<ISocketChannel>(ch =>
{
string targetHost = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
ch.Pipeline.AddLast(TlsHandler.Client(targetHost, null, (sender, certificate, chain, errors) => true));
ch.Pipeline.AddLast(new TestScenarioRunner(this.GetEchoClientScenario, testPromise));
}));
this.Output.WriteLine("Configured Bootstrap: {0}", b);
IChannel clientChannel = null;
try
{
clientChannel = await b.ConnectAsync(IPAddress.Loopback, Port);
this.Output.WriteLine("Connected channel: {0}", clientChannel);
await Task.WhenAny(testPromise.Task, Task.Delay(TimeSpan.FromMinutes(1)));
Assert.True(testPromise.Task.IsCompleted);
testPromise.Task.Wait();
}
finally
{
Task serverCloseTask = closeServerFunc();
if (clientChannel != null)
{
clientChannel.CloseAsync().Wait(TimeSpan.FromSeconds(5));
}
group.ShutdownGracefullyAsync();
if (!serverCloseTask.Wait(ShutdownTimeout))
{
this.Output.WriteLine("Didn't stop in time.");
}
}
}
示例6: RunClientAsync
static async Task RunClientAsync()
{
var eventListener = new ObservableEventListener();
eventListener.LogToConsole();
eventListener.EnableEvents(DefaultEventSource.Log, EventLevel.Verbose);
var group = new MultithreadEventLoopGroup();
X509Certificate2 cert = null;
string targetHost = null;
if (EchoClientSettings.IsSsl)
{
cert = new X509Certificate2("dotnetty.com.pfx", "password");
targetHost = cert.GetNameInfo(X509NameType.DnsName, false);
}
try
{
var bootstrap = new Bootstrap();
bootstrap
.Group(group)
.Channel<TcpSocketChannel>()
.Option(ChannelOption.TcpNodelay, true)
.Handler(new ActionChannelInitializer<ISocketChannel>(channel =>
{
IChannelPipeline pipeline = channel.Pipeline;
if (cert != null)
{
pipeline.AddLast(new TlsHandler(stream => new SslStream(stream, true, (sender, certificate, chain, errors) => true), new ClientTlsSettings(targetHost)));
}
pipeline.AddLast(new LengthFieldPrepender(2));
pipeline.AddLast(new LengthFieldBasedFrameDecoder(ushort.MaxValue, 0, 2, 0, 2));
pipeline.AddLast(new EchoClientHandler());
}));
IChannel bootstrapChannel = await bootstrap.ConnectAsync(new IPEndPoint(EchoClientSettings.Host, EchoClientSettings.Port));
Console.ReadLine();
await bootstrapChannel.CloseAsync();
}
finally
{
group.ShutdownGracefullyAsync().Wait(1000);
eventListener.Dispose();
}
}
示例7: ExtractClaims
private static IEnumerable<Claim> ExtractClaims(X509Certificate2 cert, string issuer)
{
var claims = new Collection<Claim>
{
new Claim(ClaimTypes.Thumbprint,Convert.ToBase64String(cert.GetCertHash()),
ClaimValueTypes.Base64Binary, issuer),
new Claim(ClaimTypes.X500DistinguishedName, cert.SubjectName.Name,
ClaimValueTypes.String, issuer),
new Claim(ClaimTypes.SerialNumber, cert.SerialNumber,
ClaimValueTypes.String, issuer),
new Claim(ClaimTypes.AuthenticationMethod, X509AuthnMethod,
ClaimValueTypes.String, issuer)
};
var email = cert.GetNameInfo(X509NameType.EmailName, false);
if (email != null)
{
claims.Add(new Claim(ClaimTypes.Email, email, ClaimValueTypes.String, issuer));
}
return claims;
}
示例8: CertificateLogon
/// <summary>
/// Creates a <see cref="WindowsIdentity"/> associated with a given X509 certificate.
/// </summary>
/// <param name="x509Certificate">The certificate to use to map to the associated <see cref="WindowsIdentity"/></param>
/// <returns></returns>
public static WindowsIdentity CertificateLogon(X509Certificate2 x509Certificate)
{
// for Vista, LsaLogon supporting mapping cert to NTToken
if (Environment.OSVersion.Version.Major >= CryptoHelper.WindowsVistaMajorNumber)
{
return X509SecurityTokenHandler.KerberosCertificateLogon(x509Certificate);
}
else
{
// Downlevel, S4U over PrincipalName SubjectAltNames
string upn = x509Certificate.GetNameInfo(X509NameType.UpnName, false);
if (string.IsNullOrEmpty(upn))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenValidationException(SR.GetString(SR.ID4067,
X509Util.GetCertificateId(x509Certificate))));
}
return new WindowsIdentity(upn);
}
}
示例9: SubTest
public void SubTest()
{
X509Certificate2 x509 = new X509Certificate2(@"C:\Users\bxu.CHINA\Desktop\HYD-801\1234\cert\ABCFR_ABCFRALMMACC1.crt");
//X509Certificate2 x509 = new X509Certificate2(@"..\..\..\ApacheQpidClient\certificates\LiquidCapital\LCMLO_ABCFRALMMACC1.crt");
byte[] rawdata = x509.RawData;
Console.WriteLine("Content Type: {0}{1}", X509Certificate2.GetCertContentType(rawdata), Environment.NewLine);
Console.WriteLine("Friendly Name: {0}{1}", x509.FriendlyName, Environment.NewLine);
Console.WriteLine("Certificate Verified?: {0}{1}", x509.Verify(), Environment.NewLine);
Console.WriteLine("Simple Name: {0}{1}", x509.GetNameInfo(X509NameType.SimpleName, true), Environment.NewLine);
Console.WriteLine("Signature Algorithm: {0}{1}", x509.SignatureAlgorithm.FriendlyName, Environment.NewLine);
// Console.WriteLine("Private Key: {0}{1}", x509.PrivateKey.ToXmlString(false), Environment.NewLine); // cer里面并没有私钥信息
Console.WriteLine("Public Key: {0}{1}", x509.PublicKey.Key.ToXmlString(false), Environment.NewLine);
Console.WriteLine("Certificate Archived?: {0}{1}", x509.Archived, Environment.NewLine);
Console.WriteLine("Length of Raw Data: {0}{1}", x509.RawData.Length, Environment.NewLine);
Console.WriteLine("SubjectName: {0}{1}", x509.SubjectName, Environment.NewLine);
Console.WriteLine("Subject: {0}{1}", x509.Subject, Environment.NewLine);
}
示例10: Certificate_9_Properties
public void Certificate_9_Properties ()
{
DateTime expectedNotAfter = new DateTime (630077183990000000,
DateTimeKind.Utc);
DateTime expectedNotBefore = new DateTime (629761824000000000,
DateTimeKind.Utc);
X509Certificate2 x = new X509Certificate2 (cert_9);
Assert.IsFalse (x.Archived, "Archived");
Assert.AreEqual (5, x.Extensions.Count, "Extensions");
Assert.AreEqual (0, x.FriendlyName.Length, "FriendlyName");
Assert.IsFalse (x.HasPrivateKey, "HasPrivateKey");
Assert.AreEqual ("OU=VeriSign Class 1 CA - Individual Subscriber, O=\"VeriSign, Inc.\", L=Internet", x.Issuer, "Issuer");
Assert.AreEqual ("OU=VeriSign Class 1 CA - Individual Subscriber, O=\"VeriSign, Inc.\", L=Internet", x.IssuerName.Name, "IssuerName");
Assert.AreEqual (expectedNotAfter.Ticks, x.NotAfter.ToUniversalTime ().Ticks, "NotAfter#1");
Assert.AreEqual (DateTimeKind.Local, x.NotAfter.Kind, "NotAfter#2");
Assert.AreEqual (expectedNotAfter.ToLocalTime (), x.NotAfter, "NotAfter#3");
Assert.AreEqual (expectedNotBefore.Ticks, x.NotBefore.ToUniversalTime ().Ticks, "NotBefore#1");
Assert.AreEqual (DateTimeKind.Local, x.NotBefore.Kind, "NotBefore#2");
Assert.AreEqual (expectedNotBefore.ToLocalTime (), x.NotBefore, "NotBefore#3");
Assert.IsNull (x.PrivateKey, "PrivateKey");
Assert.AreEqual ("<RSAKeyValue><Modulus>xYEHousPuP/4+BzuMv+/EjVq+WvIvi/7Pq8EUUqs3RApqM1AW2YemO/yTHf6j4bRIWeSRErEicmDz4ifb+IyNQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", x.PublicKey.Key.ToXmlString (false), "PublicKey");
Assert.AreEqual (cert_9, x.RawData, "RawData");
Assert.AreEqual ("200B355ECEC4B063B7DEC634B9703444", x.SerialNumber, "SerialNumber");
Assert.AreEqual ("1.2.840.113549.1.1.4", x.SignatureAlgorithm.Value, "SignatureAlgorithm");
Assert.AreEqual ("[email protected], CN=David T. Gray, OU=Digital ID Class 1 - Netscape, OU=\"www.verisign.com/repository/CPS Incorp. by Ref.,LIAB.LTD(c)96\", OU=VeriSign Class 1 CA - Individual Subscriber, O=\"VeriSign, Inc.\", L=Internet", x.Subject, "Subject");
Assert.AreEqual ("[email protected], CN=David T. Gray, OU=Digital ID Class 1 - Netscape, OU=\"www.verisign.com/repository/CPS Incorp. by Ref.,LIAB.LTD(c)96\", OU=VeriSign Class 1 CA - Individual Subscriber, O=\"VeriSign, Inc.\", L=Internet", x.SubjectName.Name, "SubjectName");
Assert.AreEqual ("52D1848F6A161BA5C6C19007F8164668F5A3B2CF", x.Thumbprint, "Thumbprint");
Assert.AreEqual (3, x.Version, "Version");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, true), "DnsFromAlternativeName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsName, true), "DnsName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, true), "EmailName,true");
Assert.AreEqual ("VeriSign Class 1 CA - Individual Subscriber", x.GetNameInfo (X509NameType.SimpleName, true), "SimpleName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, true), "UpnName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, true), "UrlName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, false), "DnsFromAlternativeName,false");
Assert.AreEqual ("David T. Gray", x.GetNameInfo (X509NameType.DnsName, false), "DnsName,false");
Assert.AreEqual ("[email protected]", x.GetNameInfo (X509NameType.EmailName, false), "EmailName,false");
Assert.AreEqual ("David T. Gray", x.GetNameInfo (X509NameType.SimpleName, false), "SimpleName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, false), "UpnName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, false), "UrlName,false");
// extensions
X509Extension ext = x.Extensions[0];
Assert.AreEqual ("2.5.29.19", ext.Oid.Value, "Oid-0");
Assert.AreEqual ("30-00", BitConverter.ToString (ext.RawData), "RawData-0");
Assert.IsFalse (ext.Critical, "Critical-0");
X509BasicConstraintsExtension bce = (X509BasicConstraintsExtension) ext;
Assert.IsFalse (bce.CertificateAuthority, "CertificateAuthority");
Assert.IsFalse (bce.HasPathLengthConstraint, "HasPathLengthConstraint");
Assert.AreEqual (0, bce.PathLengthConstraint, "PathLengthConstraint");
ext = x.Extensions[1];
Assert.AreEqual ("2.5.29.3", ext.Oid.Value, "Oid-1");
Assert.AreEqual ("30-82-02-12-30-82-02-0E-30-82-02-0A-06-0B-60-86-48-01-86-F8-45-01-07-01-01-30-82-01-F9-16-82-01-A7-54-68-69-73-20-63-65-72-74-69-66-69-63-61-74-65-20-69-6E-63-6F-72-70-6F-72-61-74-65-73-20-62-79-20-72-65-66-65-72-65-6E-63-65-2C-20-61-6E-64-20-69-74-73-20-75-73-65-20-69-73-20-73-74-72-69-63-74-6C-79-20-73-75-62-6A-65-63-74-20-74-6F-2C-20-74-68-65-20-56-65-72-69-53-69-67-6E-20-43-65-72-74-69-66-69-63-61-74-69-6F-6E-20-50-72-61-63-74-69-63-65-20-53-74-61-74-65-6D-65-6E-74-20-28-43-50-53-29-2C-20-61-76-61-69-6C-61-62-6C-65-20-61-74-3A-20-68-74-74-70-73-3A-2F-2F-77-77-77-2E-76-65-72-69-73-69-67-6E-2E-63-6F-6D-2F-43-50-53-3B-20-62-79-20-45-2D-6D-61-69-6C-20-61-74-20-43-50-53-2D-72-65-71-75-65-73-74-73-40-76-65-72-69-73-69-67-6E-2E-63-6F-6D-3B-20-6F-72-20-62-79-20-6D-61-69-6C-20-61-74-20-56-65-72-69-53-69-67-6E-2C-20-49-6E-63-2E-2C-20-32-35-39-33-20-43-6F-61-73-74-20-41-76-65-2E-2C-20-4D-6F-75-6E-74-61-69-6E-20-56-69-65-77-2C-20-43-41-20-39-34-30-34-33-20-55-53-41-20-54-65-6C-2E-20-2B-31-20-28-34-31-35-29-20-39-36-31-2D-38-38-33-30-20-43-6F-70-79-72-69-67-68-74-20-28-63-29-20-31-39-39-36-20-56-65-72-69-53-69-67-6E-2C-20-49-6E-63-2E-20-20-41-6C-6C-20-52-69-67-68-74-73-20-52-65-73-65-72-76-65-64-2E-20-43-45-52-54-41-49-4E-20-57-41-52-52-41-4E-54-49-45-53-20-44-49-53-43-4C-41-49-4D-45-44-20-61-6E-64-20-4C-49-41-42-49-4C-49-54-59-20-4C-49-4D-49-54-45-44-2E-A0-0E-06-0C-60-86-48-01-86-F8-45-01-07-01-01-01-A1-0E-06-0C-60-86-48-01-86-F8-45-01-07-01-01-02-30-2C-30-2A-16-28-68-74-74-70-73-3A-2F-2F-77-77-77-2E-76-65-72-69-73-69-67-6E-2E-63-6F-6D-2F-72-65-70-6F-73-69-74-6F-72-79-2F-43-50-53-20", BitConverter.ToString (ext.RawData), "RawData-1");
Assert.IsFalse (ext.Critical, "Critical-1");
ext = x.Extensions[2];
Assert.AreEqual ("2.16.840.1.113730.1.1", ext.Oid.Value, "Oid-2");
Assert.AreEqual ("03-02-07-80", BitConverter.ToString (ext.RawData), "RawData-2");
Assert.IsFalse (ext.Critical, "Critical-2");
ext = x.Extensions[3];
Assert.AreEqual ("2.16.840.1.113730.1.8", ext.Oid.Value, "Oid-3");
Assert.AreEqual ("16-27-68-74-74-70-73-3A-2F-2F-77-77-77-2E-76-65-72-69-73-69-67-6E-2E-63-6F-6D-2F-72-65-70-6F-73-69-74-6F-72-79-2F-43-50-53", BitConverter.ToString (ext.RawData), "RawData-3");
Assert.IsFalse (ext.Critical, "Critical-3");
ext = x.Extensions[4];
Assert.AreEqual ("2.16.840.1.113730.1.13", ext.Oid.Value, "Oid-4");
Assert.AreEqual ("16-82-04-74-43-41-55-54-49-4F-4E-3A-20-54-68-65-20-43-6F-6D-6D-6F-6E-20-4E-61-6D-65-20-69-6E-20-74-68-69-73-20-43-6C-61-73-73-20-31-20-44-69-67-69-74-61-6C-20-0A-49-44-20-69-73-20-6E-6F-74-20-61-75-74-68-65-6E-74-69-63-61-74-65-64-20-62-79-20-56-65-72-69-53-69-67-6E-2E-20-49-74-20-6D-61-79-20-62-65-20-74-68-65-0A-68-6F-6C-64-65-72-27-73-20-72-65-61-6C-20-6E-61-6D-65-20-6F-72-20-61-6E-20-61-6C-69-61-73-2E-20-56-65-72-69-53-69-67-6E-20-64-6F-65-73-20-61-75-74-68-2D-0A-65-6E-74-69-63-61-74-65-20-74-68-65-20-65-2D-6D-61-69-6C-20-61-64-64-72-65-73-73-20-6F-66-20-74-68-65-20-68-6F-6C-64-65-72-2E-0A-0A-54-68-69-73-20-63-65-72-74-69-66-69-63-61-74-65-20-69-6E-63-6F-72-70-6F-72-61-74-65-73-20-62-79-20-72-65-66-65-72-65-6E-63-65-2C-20-61-6E-64-20-0A-69-74-73-20-75-73-65-20-69-73-20-73-74-72-69-63-74-6C-79-20-73-75-62-6A-65-63-74-20-74-6F-2C-20-74-68-65-20-56-65-72-69-53-69-67-6E-20-0A-43-65-72-74-69-66-69-63-61-74-69-6F-6E-20-50-72-61-63-74-69-63-65-20-53-74-61-74-65-6D-65-6E-74-20-28-43-50-53-29-2C-20-61-76-61-69-6C-61-62-6C-65-0A-69-6E-20-74-68-65-20-56-65-72-69-53-69-67-6E-20-72-65-70-6F-73-69-74-6F-72-79-20-61-74-3A-20-0A-68-74-74-70-73-3A-2F-2F-77-77-77-2E-76-65-72-69-73-69-67-6E-2E-63-6F-6D-3B-20-62-79-20-45-2D-6D-61-69-6C-20-61-74-0A-43-50-53-2D-72-65-71-75-65-73-74-73-40-76-65-72-69-73-69-67-6E-2E-63-6F-6D-3B-20-6F-72-20-62-79-20-6D-61-69-6C-20-61-74-20-56-65-72-69-53-69-67-6E-2C-0A-49-6E-63-2E-2C-20-32-35-39-33-20-43-6F-61-73-74-20-41-76-65-2E-2C-20-4D-6F-75-6E-74-61-69-6E-20-56-69-65-77-2C-20-43-41-20-39-34-30-34-33-20-55-53-41-0A-0A-43-6F-70-79-72-69-67-68-74-20-28-63-29-31-39-39-36-20-56-65-72-69-53-69-67-6E-2C-20-49-6E-63-2E-20-20-41-6C-6C-20-52-69-67-68-74-73-20-0A-52-65-73-65-72-76-65-64-2E-20-43-45-52-54-41-49-4E-20-57-41-52-52-41-4E-54-49-45-53-20-44-49-53-43-4C-41-49-4D-45-44-20-41-4E-44-20-0A-4C-49-41-42-49-4C-49-54-59-20-4C-49-4D-49-54-45-44-2E-0A-0A-57-41-52-4E-49-4E-47-3A-20-54-48-45-20-55-53-45-20-4F-46-20-54-48-49-53-20-43-45-52-54-49-46-49-43-41-54-45-20-49-53-20-53-54-52-49-43-54-4C-59-0A-53-55-42-4A-45-43-54-20-54-4F-20-54-48-45-20-56-45-52-49-53-49-47-4E-20-43-45-52-54-49-46-49-43-41-54-49-4F-4E-20-50-52-41-43-54-49-43-45-0A-53-54-41-54-45-4D-45-4E-54-2E-20-20-54-48-45-20-49-53-53-55-49-4E-47-20-41-55-54-48-4F-52-49-54-59-20-44-49-53-43-4C-41-49-4D-53-20-43-45-52-54-41-49-4E-0A-49-4D-50-4C-49-45-44-20-41-4E-44-20-45-58-50-52-45-53-53-20-57-41-52-52-41-4E-54-49-45-53-2C-20-49-4E-43-4C-55-44-49-4E-47-20-57-41-52-52-41-4E-54-49-45-53-0A-4F-46-20-4D-45-52-43-48-41-4E-54-41-42-49-4C-49-54-59-20-4F-52-20-46-49-54-4E-45-53-53-20-46-4F-52-20-41-20-50-41-52-54-49-43-55-4C-41-52-0A-50-55-52-50-4F-53-45-2C-20-41-4E-44-20-57-49-4C-4C-20-4E-4F-54-20-42-45-20-4C-49-41-42-4C-45-20-46-4F-52-20-43-4F-4E-53-45-51-55-45-4E-54-49-41-4C-2C-0A-50-55-4E-49-54-49-56-45-2C-20-41-4E-44-20-43-45-52-54-41-49-4E-20-4F-54-48-45-52-20-44-41-4D-41-47-45-53-2E-20-53-45-45-20-54-48-45-20-43-50-53-0A-46-4F-52-20-44-45-54-41-49-4C-53-2E-0A-0A-43-6F-6E-74-65-6E-74-73-20-6F-66-20-74-68-65-20-56-65-72-69-53-69-67-6E-20-72-65-67-69-73-74-65-72-65-64-0A-6E-6F-6E-76-65-72-69-66-69-65-64-53-75-62-6A-65-63-74-41-74-74-72-69-62-75-74-65-73-20-65-78-74-65-6E-73-69-6F-6E-20-76-61-6C-75-65-20-73-68-61-6C-6C-20-0A-6E-6F-74-20-62-65-20-63-6F-6E-73-69-64-65-72-65-64-20-61-73-20-61-63-63-75-72-61-74-65-20-69-6E-66-6F-72-6D-61-74-69-6F-6E-20-76-61-6C-69-64-61-74-65-64-20-0A-62-79-20-74-68-65-20-49-41-2E", BitConverter.ToString (ext.RawData), "RawData-4");
Assert.IsFalse (ext.Critical, "Critical-4");
}
示例11: Certificate_8_Properties
public void Certificate_8_Properties ()
{
DateTime expectedNotAfter = new DateTime (631769760000000000,
DateTimeKind.Utc);
DateTime expectedNotBefore = new DateTime (631080288000000000,
DateTimeKind.Utc);
X509Certificate2 x = new X509Certificate2 (cert_8);
Assert.IsFalse (x.Archived, "Archived");
Assert.AreEqual (2, x.Extensions.Count, "Extensions");
Assert.AreEqual (0, x.FriendlyName.Length, "FriendlyName");
Assert.IsFalse (x.HasPrivateKey, "HasPrivateKey");
Assert.AreEqual ("CN=Armed Forces Root, OU=DoD, O=U.S. Government, C=US", x.Issuer, "Issuer");
Assert.AreEqual ("CN=Armed Forces Root, OU=DoD, O=U.S. Government, C=US", x.IssuerName.Name, "IssuerName");
Assert.AreEqual (expectedNotAfter.Ticks, x.NotAfter.ToUniversalTime ().Ticks, "NotAfter#1");
Assert.AreEqual (DateTimeKind.Local, x.NotAfter.Kind, "NotAfter#2");
Assert.AreEqual (expectedNotAfter.ToLocalTime (), x.NotAfter, "NotAfter#3");
Assert.AreEqual (expectedNotBefore.Ticks, x.NotBefore.ToUniversalTime ().Ticks, "NotBefore#1");
Assert.AreEqual (DateTimeKind.Local, x.NotBefore.Kind, "NotBefore#2");
Assert.AreEqual (expectedNotBefore.ToLocalTime (), x.NotBefore, "NotBefore#3");
Assert.IsNull (x.PrivateKey, "PrivateKey");
Assert.AreEqual ("<DSAKeyValue><P>kIk+GBv+ox0WiQC01UCCTC7sPWYNDbkXQG46XAN7G5MoDO+5l+Oh6+KjfGHdb9WtFWkAFrLDCD3EWcbycKWw9R8d9LAV2n4oOSSZNlvsOSX6kkll0kMFap6je/Deoy/Tbzr5NcMp1EVsVpreNm7+EmiWe0UdLP+5LfVSjN8+L2M=</P><Q>gam10ATym6fYVUw7MqFFMk/1Ud0=</Q><G>ZHqIC/I+kYFZnPTqxnsOvuoF6Hf9IDSHocRp9siLGdrN+iGKV6l6JgpW1O1LG3xw7bTmemre0yni6Zoz7QmNnt/aLkrBUJLuL+Va84ViakjcGwKYprDRCUsQ0fD64LEdE1RLwKhA73HoVmuiKcseCX0nOZE7IE+YOeg5ypjFr1Q=</G><Y>VKiItY8BVs4Yj6bWfCkpdUXoMaQHF+0eXbJ7u848l2ceiAr+fQAiJx1m7vYbtpV/Wv8GNAJDw4PEZiyhBQ5os8rc0/kMwGbfhYRLIF1BrMDsN5IOlxm/UzVjJxgzNUJN8C1tp6SYqlfz0rhuTo//vm9ODwtEJO7fTCJbRJiUy7g=</Y></DSAKeyValue>", x.PublicKey.Key.ToXmlString (false), "PublicKey");
Assert.AreEqual (cert_8, x.RawData, "RawData");
Assert.AreEqual ("03", x.SerialNumber, "SerialNumber");
Assert.AreEqual ("1.2.840.10040.4.3", x.SignatureAlgorithm.Value, "SignatureAlgorithm");
Assert.AreEqual ("CN=Armed Forces Root, OU=DoD, O=U.S. Government, C=US", x.Subject, "Subject");
Assert.AreEqual ("CN=Armed Forces Root, OU=DoD, O=U.S. Government, C=US", x.SubjectName.Name, "SubjectName");
Assert.AreEqual ("A30A06B1B0D4F871678A60C54EE4D8663606CCE6", x.Thumbprint, "Thumbprint");
Assert.AreEqual (3, x.Version, "Version");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, true), "DnsFromAlternativeName,true");
Assert.AreEqual ("Armed Forces Root", x.GetNameInfo (X509NameType.DnsName, true), "DnsName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, true), "EmailName,true");
Assert.AreEqual ("Armed Forces Root", x.GetNameInfo (X509NameType.SimpleName, true), "SimpleName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, true), "UpnName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, true), "UrlName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, false), "DnsFromAlternativeName,false");
Assert.AreEqual ("Armed Forces Root", x.GetNameInfo (X509NameType.DnsName, false), "DnsName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, false), "EmailName,false");
Assert.AreEqual ("Armed Forces Root", x.GetNameInfo (X509NameType.SimpleName, false), "SimpleName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, false), "UpnName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, false), "UrlName,false");
// extensions
X509Extension ext = x.Extensions[0];
Assert.AreEqual ("2.5.29.14", ext.Oid.Value, "Oid-0");
Assert.AreEqual ("04-14-9D-2D-73-C3-B8-E3-4D-29-28-C3-65-BE-A9-98-CB-D6-8A-06-68-9C", BitConverter.ToString (ext.RawData), "RawData-0");
Assert.IsFalse (ext.Critical, "Critical-0");
X509SubjectKeyIdentifierExtension ski = (X509SubjectKeyIdentifierExtension) ext;
Assert.AreEqual ("9D2D73C3B8E34D2928C365BEA998CBD68A06689C", ski.SubjectKeyIdentifier, "SubjectKeyIdentifier");
ext = x.Extensions[1];
Assert.AreEqual ("2.5.29.19", ext.Oid.Value, "Oid-1");
Assert.AreEqual ("30-03-01-01-FF", BitConverter.ToString (ext.RawData), "RawData-1");
Assert.IsFalse (ext.Critical, "Critical-1");
X509BasicConstraintsExtension bce = (X509BasicConstraintsExtension) ext;
Assert.IsTrue (bce.CertificateAuthority, "CertificateAuthority");
Assert.IsFalse (bce.HasPathLengthConstraint, "HasPathLengthConstraint");
Assert.AreEqual (0, bce.PathLengthConstraint, "PathLengthConstraint");
}
示例12: Certificate_5_Properties
public void Certificate_5_Properties ()
{
DateTime expectedNotAfter = new DateTime (632254464000000000,
DateTimeKind.Utc);
DateTime expectedNotBefore = new DateTime (630045216000000000,
DateTimeKind.Utc);
X509Certificate2 x = new X509Certificate2 (cert_5);
Assert.IsFalse (x.Archived, "Archived");
Assert.AreEqual (6, x.Extensions.Count, "Extensions");
Assert.AreEqual (0, x.FriendlyName.Length, "FriendlyName");
Assert.IsFalse (x.HasPrivateKey, "HasPrivateKey");
Assert.AreEqual ("O=SET Root, C=US", x.Issuer, "Issuer");
Assert.AreEqual ("O=SET Root, C=US", x.IssuerName.Name, "IssuerName");
Assert.AreEqual (expectedNotAfter.Ticks, x.NotAfter.ToUniversalTime ().Ticks, "NotAfter#1");
Assert.AreEqual (DateTimeKind.Local, x.NotAfter.Kind, "NotAfter#2");
Assert.AreEqual (expectedNotAfter.ToLocalTime (), x.NotAfter, "NotAfter#3");
Assert.AreEqual (expectedNotBefore.Ticks, x.NotBefore.ToUniversalTime ().Ticks, "NotBefore#1");
Assert.AreEqual (DateTimeKind.Local, x.NotBefore.Kind, "NotBefore#2");
Assert.AreEqual (expectedNotBefore.ToLocalTime (), x.NotBefore, "NotBefore#3");
Assert.IsNull (x.PrivateKey, "PrivateKey");
Assert.AreEqual ("<RSAKeyValue><Modulus>1Nw+uuGU977N7SF3z9qIWFEOj/TaABQeDaettpZaxtPsJe3YQwtufz+eHnSgHpd2MMpvCmPAozFAJYC4vSjrfXULTkE0xCAAwsv0miAAWNn0QBMYdwy1BN63tkOLpMw2dnnFCxfLfoihM7DTNCe/O2HaxSDr+ZSai3myqI7LwdmUSplmUFWygyh9Ij3s3KPoOduDVMmJqd9ZUp9673wRYlLs5me6PeqrR9vk9B9zwz3sfoR9Lyn+bBc/dW1WbsBOtb8qIIrkV67ALmjJCc+FdwrvOjfLYExFc3+QPoYd+sP8UIqyxYo08PJD7jxWuiTp4KWHHnwwM3f9XeBXDWwZOQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", x.PublicKey.Key.ToXmlString (false), "PublicKey");
Assert.AreEqual (cert_5, x.RawData, "RawData");
Assert.AreEqual ("6A", x.SerialNumber, "SerialNumber");
Assert.AreEqual ("1.2.840.113549.1.1.5", x.SignatureAlgorithm.Value, "SignatureAlgorithm");
Assert.AreEqual ("O=SET Root, C=US", x.Subject, "Subject");
Assert.AreEqual ("O=SET Root, C=US", x.SubjectName.Name, "SubjectName");
Assert.AreEqual ("63DB7A42673975392AC6A4FAE3D78446B467C326", x.Thumbprint, "Thumbprint");
Assert.AreEqual (3, x.Version, "Version");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, true), "DnsFromAlternativeName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsName, true), "DnsName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, true), "EmailName,true");
Assert.AreEqual ("SET Root", x.GetNameInfo (X509NameType.SimpleName, true), "SimpleName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, true), "UpnName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, true), "UrlName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, false), "DnsFromAlternativeName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsName, false), "DnsName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, false), "EmailName,false");
Assert.AreEqual ("SET Root", x.GetNameInfo (X509NameType.SimpleName, false), "SimpleName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, false), "UpnName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, false), "UrlName,false");
// extensions
X509Extension ext = x.Extensions[0];
Assert.AreEqual ("2.5.29.19", ext.Oid.Value, "Oid-0");
Assert.AreEqual ("30-06-01-01-FF-02-01-03", BitConverter.ToString (ext.RawData), "RawData-0");
Assert.IsTrue (ext.Critical, "Critical-0");
X509BasicConstraintsExtension bce = (X509BasicConstraintsExtension) ext;
Assert.IsTrue (bce.CertificateAuthority, "CertificateAuthority");
Assert.IsTrue (bce.HasPathLengthConstraint, "HasPathLengthConstraint");
Assert.AreEqual (3, bce.PathLengthConstraint, "PathLengthConstraint");
ext = x.Extensions[1];
Assert.AreEqual ("2.5.29.32", ext.Oid.Value, "Oid-1");
Assert.AreEqual ("30-82-02-B9-30-82-02-B5-06-04-67-2A-05-00-30-82-02-AB-30-82-02-A7-06-04-67-2A-07-06-30-82-02-9D-30-82-02-99-1A-82-02-95-54-68-69-73-20-53-45-54-20-52-6F-6F-74-20-43-65-72-74-69-66-69-63-61-74-65-20-61-6E-64-20-61-6E-79-20-63-65-72-74-69-66-69-63-61-74-65-20-61-75-74-68-65-6E-74-69-63-61-74-65-64-20-64-69-72-65-63-74-6C-79-20-6F-72-20-69-6E-64-69-72-65-63-74-6C-79-20-62-79-20-74-68-69-73-20-63-65-72-74-69-66-69-63-61-74-65-2C-20-6D-61-79-20-6F-6E-6C-79-20-62-65-20-75-73-65-64-20-74-6F-20-65-6E-61-62-6C-65-20-22-53-65-63-75-72-65-20-46-69-6E-61-6E-63-69-61-6C-20-54-72-61-6E-73-61-63-74-69-6F-6E-73-22-20-61-73-20-64-65-66-69-6E-65-64-20-69-6E-20-74-68-65-20-53-45-54-20-52-6F-6F-74-20-43-65-72-74-69-66-69-63-61-74-65-20-50-72-61-63-74-69-63-65-20-53-74-61-74-65-6D-65-6E-74-20-61-6E-64-2C-20-77-68-65-6E-20-61-70-70-72-6F-70-72-69-61-74-65-2C-20-69-6E-20-61-20-53-45-54-20-42-72-61-6E-64-20-43-65-72-74-69-66-69-63-61-74-65-20-50-72-61-63-74-69-63-65-20-53-74-61-74-65-6D-65-6E-74-2E-20-20-4E-6F-20-50-61-72-74-79-20-6D-61-79-20-72-65-6C-79-20-75-70-6F-6E-20-74-68-65-20-53-45-54-20-52-6F-6F-74-20-43-65-72-74-69-66-69-63-61-74-65-20-66-6F-72-20-61-6E-79-20-6F-74-68-65-72-20-70-75-72-70-6F-73-65-2E-20-20-41-20-53-45-54-20-42-72-61-6E-64-20-73-68-61-6C-6C-20-62-65-20-61-6E-79-20-70-61-79-6D-65-6E-74-20-62-72-61-6E-64-20-77-68-6F-73-65-20-53-45-54-20-63-65-72-74-69-66-69-63-61-74-65-20-69-73-20-73-69-67-6E-65-64-20-62-79-20-74-68-65-20-70-72-69-76-61-74-65-20-6B-65-79-20-63-6F-72-72-65-73-70-6F-6E-64-69-6E-67-20-74-6F-20-74-68-65-20-70-75-62-6C-69-63-20-6B-65-79-20-63-6F-6E-74-61-69-6E-65-64-20-69-6E-20-74-68-69-73-20-63-65-72-74-69-66-69-63-61-74-65-2E-20-20-41-6C-6C-20-6D-61-74-74-65-72-73-20-72-65-6C-61-74-69-6E-67-20-74-6F-20-75-73-61-67-65-2C-20-6C-69-61-62-69-6C-69-74-79-20-61-6E-64-20-70-72-6F-63-65-64-75-72-65-73-20-77-69-74-68-20-53-45-54-20-63-65-72-74-69-66-69-63-61-74-65-73-20-69-73-73-75-65-64-20-62-65-6E-65-61-74-68-20-61-20-53-45-54-20-42-72-61-6E-64-20-73-68-61-6C-6C-20-62-65-20-64-65-74-65-72-6D-69-6E-65-64-20-62-79-20-74-68-61-74-20-53-45-54-20-42-72-61-6E-64-2E", BitConverter.ToString (ext.RawData), "RawData-1");
Assert.IsTrue (ext.Critical, "Critical-1");
ext = x.Extensions[2];
Assert.AreEqual ("2.5.29.15", ext.Oid.Value, "Oid-2");
Assert.AreEqual ("03-02-01-06", BitConverter.ToString (ext.RawData), "RawData-2");
Assert.IsTrue (ext.Critical, "Critical-2");
X509KeyUsageExtension kue = (X509KeyUsageExtension) ext;
Assert.AreEqual (X509KeyUsageFlags.CrlSign | X509KeyUsageFlags.KeyCertSign, kue.KeyUsages, "KeyUsages");
ext = x.Extensions[3];
Assert.AreEqual ("2.5.29.16", ext.Oid.Value, "Oid-3");
Assert.AreEqual ("30-22-80-0F-31-39-39-37-30-37-31-35-30-30-30-30-30-30-5A-81-0F-31-39-39-38-30-37-31-35-30-30-30-30-30-30-5A", BitConverter.ToString (ext.RawData), "RawData-3");
Assert.IsFalse (ext.Critical, "Critical-3");
ext = x.Extensions[4];
Assert.AreEqual ("2.23.42.7.1", ext.Oid.Value, "Oid-4");
Assert.AreEqual ("03-03-07-00-80", BitConverter.ToString (ext.RawData), "RawData-4");
Assert.IsTrue (ext.Critical, "Critical-4");
ext = x.Extensions[5];
Assert.AreEqual ("2.23.42.7.0", ext.Oid.Value, "Oid-5");
Assert.AreEqual ("30-2F-30-2D-02-01-00-30-09-06-05-2B-0E-03-02-1A-05-00-30-07-06-05-67-2A-03-00-00-04-14-C8-57-44-4F-D7-91-56-3E-C6-F3-E0-E6-08-2E-9A-AF-61-11-43-5D", BitConverter.ToString (ext.RawData), "RawData-5");
Assert.IsTrue (ext.Critical, "Critical-5");
}
示例13: Certificate_4_Properties
public void Certificate_4_Properties ()
{
DateTime expectedNotAfter = new DateTime (630822812570000000,
DateTimeKind.Utc);
DateTime expectedNotBefore = new DateTime (629200220570000000,
DateTimeKind.Utc);
X509Certificate2 x = new X509Certificate2 (cert_4);
Assert.IsFalse (x.Archived, "Archived");
Assert.AreEqual (0, x.Extensions.Count, "Extensions");
Assert.AreEqual (0, x.FriendlyName.Length, "FriendlyName");
Assert.IsFalse (x.HasPrivateKey, "HasPrivateKey");
Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x.Issuer, "Issuer");
Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x.IssuerName.Name, "IssuerName");
Assert.AreEqual (expectedNotAfter.Ticks, x.NotAfter.ToUniversalTime ().Ticks, "NotAfter#1");
Assert.AreEqual (DateTimeKind.Local, x.NotAfter.Kind, "NotAfter#2");
Assert.AreEqual (expectedNotAfter.ToLocalTime (), x.NotAfter, "NotAfter#3");
Assert.AreEqual (expectedNotBefore.Ticks, x.NotBefore.ToUniversalTime ().Ticks, "NotBefore#1");
Assert.AreEqual (DateTimeKind.Local, x.NotBefore.Kind, "NotBefore#2");
Assert.AreEqual (expectedNotBefore.ToLocalTime (), x.NotBefore, "NotBefore#3");
Assert.IsNull (x.PrivateKey, "PrivateKey");
Assert.AreEqual ("<RSAKeyValue><Modulus>ks56wa6DPlqqiYNXrCUBdgytro4sN87rNXhkVAPlhEBRyb+PCOKKggjSFoY3VemxIQKtdmiBmgWiS8lLJWYiVmyIB4/3gVlthAdlcBNxdj6bd0zjUIlWmEi5HacpGhMuShFZnB4V1UlULHM6aYKxlzmcbXBnSOXdLdbIHns=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>", x.PublicKey.Key.ToXmlString (false), "PublicKey");
Assert.AreEqual (cert_4, x.RawData, "RawData");
Assert.AreEqual ("0241000001", x.SerialNumber, "SerialNumber");
Assert.AreEqual ("1.2.840.113549.1.1.2", x.SignatureAlgorithm.Value, "SignatureAlgorithm");
Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x.Subject, "Subject");
Assert.AreEqual ("OU=Secure Server Certification Authority, O=\"RSA Data Security, Inc.\", C=US", x.SubjectName.Name, "SubjectName");
Assert.AreEqual ("0D974461703713CB74932D2A75ACBC714B281266", x.Thumbprint, "Thumbprint");
Assert.AreEqual (1, x.Version, "Version");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, true), "DnsFromAlternativeName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsName, true), "DnsName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, true), "EmailName,true");
Assert.AreEqual ("Secure Server Certification Authority", x.GetNameInfo (X509NameType.SimpleName, true), "SimpleName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, true), "UpnName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, true), "UrlName,true");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsFromAlternativeName, false), "DnsFromAlternativeName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.DnsName, false), "DnsName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.EmailName, false), "EmailName,false");
Assert.AreEqual ("Secure Server Certification Authority", x.GetNameInfo (X509NameType.SimpleName, false), "SimpleName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UpnName, false), "UpnName,false");
Assert.AreEqual (String.Empty, x.GetNameInfo (X509NameType.UrlName, false), "UrlName,false");
}
示例14: getSimpleNameOfSubject
public static string getSimpleNameOfSubject(X509Certificate2 cert)
{
return cert.GetNameInfo(X509NameType.SimpleName, false);
}
示例15: GetCommonName
string GetCommonName(X509Certificate2 cert)
{
return cert.GetNameInfo(X509NameType.SimpleName, false);
}