X500DistinguishedName Construtores
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Inicializa uma nova instância da classe X500DistinguishedName.
Sobrecargas
X500DistinguishedName(Byte[]) |
Inicializa uma nova instância da classe X500DistinguishedName usando informações da matriz de bytes especificada. |
X500DistinguishedName(ReadOnlySpan<Byte>) |
Inicializa uma nova instância da classe X500DistinguishedName usando informações dos dados fornecidos. |
X500DistinguishedName(AsnEncodedData) |
Inicializa uma nova instância da classe X500DistinguishedName usando o objeto AsnEncodedData especificado. |
X500DistinguishedName(X500DistinguishedName) |
Inicializa uma nova instância da classe X500DistinguishedName usando o objeto X500DistinguishedName especificado. |
X500DistinguishedName(String) |
Inicializa uma nova instância da classe X500DistinguishedName usando informações da cadeia de caracteres especificada. |
X500DistinguishedName(String, X500DistinguishedNameFlags) |
Inicializa uma nova instância da classe X500DistinguishedName usando a cadeia de caracteres e o sinalizador X500DistinguishedNameFlags especificados. |
X500DistinguishedName(Byte[])
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando informações da matriz de bytes especificada.
public:
X500DistinguishedName(cli::array <System::Byte> ^ encodedDistinguishedName);
public X500DistinguishedName (byte[] encodedDistinguishedName);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : byte[] -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (encodedDistinguishedName As Byte())
Parâmetros
- encodedDistinguishedName
- Byte[]
Uma matriz de bytes que contém informações de nome diferenciado.
Exemplos
O exemplo de código a seguir mostra como usar a X500DistinguishedName classe .
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class X500Sample
{
static void Main()
{
try
{
X509Store store = new("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(
X509FindType.FindByTimeValid,
DateTime.Now, false
);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
);
Console.WriteLine($"Number of certificates: {scollection.Count}{Environment.NewLine}");
foreach (X509Certificate2 x509 in scollection)
{
X500DistinguishedName dname = new(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed | X500DistinguishedNameFlags.UseSemicolons
);
Console.WriteLine("X500DistinguishedName: {0}{1}", dname.Name, Environment.NewLine);
x509.Reset();
}
store.Close();
}
catch (CryptographicException)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
Imports System.Security.Cryptography.X509Certificates
Class X500Sample
Shared s_msg As String
Shared Sub Main()
Try
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim collection As X509Certificate2Collection = store.Certificates
Dim fcollection As X509Certificate2Collection = collection.Find(X509FindType.FindByTimeValid, Date.Now, False)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
)
s_msg = "Number of certificates: " & scollection.Count & Environment.NewLine
Console.WriteLine(s_msg)
Dim x509 As X509Certificate2
For Each x509 In scollection
Dim dname As New X500DistinguishedName(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed Or X500DistinguishedNameFlags.UseSemicolons
)
s_msg = "X500DistinguishedName: " & dname.Name & Environment.NewLine
Console.WriteLine(s_msg)
x509.Reset()
Next x509
store.Close()
Catch e As Exception
s_msg = "Error: Information could not be written out for this certificate."
Console.WriteLine(s_msg)
End Try
End Sub
End Class
Comentários
A classe X500DistinguishedName herda da classe AsnEncodedData.
Aplica-se a
X500DistinguishedName(ReadOnlySpan<Byte>)
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando informações dos dados fornecidos.
public:
X500DistinguishedName(ReadOnlySpan<System::Byte> encodedDistinguishedName);
public X500DistinguishedName (ReadOnlySpan<byte> encodedDistinguishedName);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : ReadOnlySpan<byte> -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (encodedDistinguishedName As ReadOnlySpan(Of Byte))
Parâmetros
- encodedDistinguishedName
- ReadOnlySpan<Byte>
O nome diferenciado codificado.
Aplica-se a
X500DistinguishedName(AsnEncodedData)
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando o objeto AsnEncodedData especificado.
public:
X500DistinguishedName(System::Security::Cryptography::AsnEncodedData ^ encodedDistinguishedName);
public X500DistinguishedName (System.Security.Cryptography.AsnEncodedData encodedDistinguishedName);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : System.Security.Cryptography.AsnEncodedData -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (encodedDistinguishedName As AsnEncodedData)
Parâmetros
- encodedDistinguishedName
- AsnEncodedData
Um objeto AsnEncodedData que representa o nome diferenciado.
Exemplos
O exemplo de código a seguir mostra como usar a X500DistinguishedName classe .
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class X500Sample
{
static void Main()
{
try
{
X509Store store = new("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(
X509FindType.FindByTimeValid,
DateTime.Now, false
);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
);
Console.WriteLine($"Number of certificates: {scollection.Count}{Environment.NewLine}");
foreach (X509Certificate2 x509 in scollection)
{
X500DistinguishedName dname = new(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed | X500DistinguishedNameFlags.UseSemicolons
);
Console.WriteLine("X500DistinguishedName: {0}{1}", dname.Name, Environment.NewLine);
x509.Reset();
}
store.Close();
}
catch (CryptographicException)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
Imports System.Security.Cryptography.X509Certificates
Class X500Sample
Shared s_msg As String
Shared Sub Main()
Try
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim collection As X509Certificate2Collection = store.Certificates
Dim fcollection As X509Certificate2Collection = collection.Find(X509FindType.FindByTimeValid, Date.Now, False)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
)
s_msg = "Number of certificates: " & scollection.Count & Environment.NewLine
Console.WriteLine(s_msg)
Dim x509 As X509Certificate2
For Each x509 In scollection
Dim dname As New X500DistinguishedName(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed Or X500DistinguishedNameFlags.UseSemicolons
)
s_msg = "X500DistinguishedName: " & dname.Name & Environment.NewLine
Console.WriteLine(s_msg)
x509.Reset()
Next x509
store.Close()
Catch e As Exception
s_msg = "Error: Information could not be written out for this certificate."
Console.WriteLine(s_msg)
End Try
End Sub
End Class
Comentários
A classe X500DistinguishedName herda da classe AsnEncodedData.
Aplica-se a
X500DistinguishedName(X500DistinguishedName)
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando o objeto X500DistinguishedName especificado.
public:
X500DistinguishedName(System::Security::Cryptography::X509Certificates::X500DistinguishedName ^ distinguishedName);
public X500DistinguishedName (System.Security.Cryptography.X509Certificates.X500DistinguishedName distinguishedName);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : System.Security.Cryptography.X509Certificates.X500DistinguishedName -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (distinguishedName As X500DistinguishedName)
Parâmetros
- distinguishedName
- X500DistinguishedName
Um objeto X500DistinguishedName.
Exemplos
O exemplo de código a seguir mostra como usar a X500DistinguishedName classe .
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class X500Sample
{
static void Main()
{
try
{
X509Store store = new("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(
X509FindType.FindByTimeValid,
DateTime.Now, false
);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
);
Console.WriteLine($"Number of certificates: {scollection.Count}{Environment.NewLine}");
foreach (X509Certificate2 x509 in scollection)
{
X500DistinguishedName dname = new(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed | X500DistinguishedNameFlags.UseSemicolons
);
Console.WriteLine("X500DistinguishedName: {0}{1}", dname.Name, Environment.NewLine);
x509.Reset();
}
store.Close();
}
catch (CryptographicException)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
Imports System.Security.Cryptography.X509Certificates
Class X500Sample
Shared s_msg As String
Shared Sub Main()
Try
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim collection As X509Certificate2Collection = store.Certificates
Dim fcollection As X509Certificate2Collection = collection.Find(X509FindType.FindByTimeValid, Date.Now, False)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
)
s_msg = "Number of certificates: " & scollection.Count & Environment.NewLine
Console.WriteLine(s_msg)
Dim x509 As X509Certificate2
For Each x509 In scollection
Dim dname As New X500DistinguishedName(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed Or X500DistinguishedNameFlags.UseSemicolons
)
s_msg = "X500DistinguishedName: " & dname.Name & Environment.NewLine
Console.WriteLine(s_msg)
x509.Reset()
Next x509
store.Close()
Catch e As Exception
s_msg = "Error: Information could not be written out for this certificate."
Console.WriteLine(s_msg)
End Try
End Sub
End Class
Comentários
Esse construtor cria uma cópia do objeto especificado X500DistinguishedName . A classe X500DistinguishedName herda da classe AsnEncodedData.
Aplica-se a
X500DistinguishedName(String)
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando informações da cadeia de caracteres especificada.
public:
X500DistinguishedName(System::String ^ distinguishedName);
public X500DistinguishedName (string distinguishedName);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : string -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (distinguishedName As String)
Parâmetros
- distinguishedName
- String
Uma cadeia de caracteres que representa o nome diferenciado.
Exemplos
O exemplo de código a seguir mostra como usar a X500DistinguishedName classe .
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class X500Sample
{
static void Main()
{
try
{
X509Store store = new("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(
X509FindType.FindByTimeValid,
DateTime.Now, false
);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
);
Console.WriteLine($"Number of certificates: {scollection.Count}{Environment.NewLine}");
foreach (X509Certificate2 x509 in scollection)
{
X500DistinguishedName dname = new(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed | X500DistinguishedNameFlags.UseSemicolons
);
Console.WriteLine("X500DistinguishedName: {0}{1}", dname.Name, Environment.NewLine);
x509.Reset();
}
store.Close();
}
catch (CryptographicException)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
Imports System.Security.Cryptography.X509Certificates
Class X500Sample
Shared s_msg As String
Shared Sub Main()
Try
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim collection As X509Certificate2Collection = store.Certificates
Dim fcollection As X509Certificate2Collection = collection.Find(X509FindType.FindByTimeValid, Date.Now, False)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
)
s_msg = "Number of certificates: " & scollection.Count & Environment.NewLine
Console.WriteLine(s_msg)
Dim x509 As X509Certificate2
For Each x509 In scollection
Dim dname As New X500DistinguishedName(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed Or X500DistinguishedNameFlags.UseSemicolons
)
s_msg = "X500DistinguishedName: " & dname.Name & Environment.NewLine
Console.WriteLine(s_msg)
x509.Reset()
Next x509
store.Close()
Catch e As Exception
s_msg = "Error: Information could not be written out for this certificate."
Console.WriteLine(s_msg)
End Try
End Sub
End Class
Comentários
A classe X500DistinguishedName herda da classe AsnEncodedData.
Aplica-se a
X500DistinguishedName(String, X500DistinguishedNameFlags)
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
- Origem:
- X500DistinguishedName.cs
Inicializa uma nova instância da classe X500DistinguishedName usando a cadeia de caracteres e o sinalizador X500DistinguishedNameFlags especificados.
public:
X500DistinguishedName(System::String ^ distinguishedName, System::Security::Cryptography::X509Certificates::X500DistinguishedNameFlags flag);
public X500DistinguishedName (string distinguishedName, System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags flag);
new System.Security.Cryptography.X509Certificates.X500DistinguishedName : string * System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags -> System.Security.Cryptography.X509Certificates.X500DistinguishedName
Public Sub New (distinguishedName As String, flag As X500DistinguishedNameFlags)
Parâmetros
- distinguishedName
- String
Uma cadeia de caracteres que representa o nome diferenciado.
Um combinação bit a bit de valores de enumeração que especificam as características do nome diferenciado.
Exemplos
O exemplo de código a seguir mostra como usar a X500DistinguishedName classe .
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class X500Sample
{
static void Main()
{
try
{
X509Store store = new("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(
X509FindType.FindByTimeValid,
DateTime.Now, false
);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
);
Console.WriteLine($"Number of certificates: {scollection.Count}{Environment.NewLine}");
foreach (X509Certificate2 x509 in scollection)
{
X500DistinguishedName dname = new(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed | X500DistinguishedNameFlags.UseSemicolons
);
Console.WriteLine("X500DistinguishedName: {0}{1}", dname.Name, Environment.NewLine);
x509.Reset();
}
store.Close();
}
catch (CryptographicException)
{
Console.WriteLine("Information could not be written out for this certificate.");
}
}
}
Imports System.Security.Cryptography.X509Certificates
Class X500Sample
Shared s_msg As String
Shared Sub Main()
Try
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)
Dim collection As X509Certificate2Collection = store.Certificates
Dim fcollection As X509Certificate2Collection = collection.Find(X509FindType.FindByTimeValid, Date.Now, False)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(
fcollection,
"Test Certificate Select",
"Select a certificate from the following list to get information on that certificate",
X509SelectionFlag.MultiSelection
)
s_msg = "Number of certificates: " & scollection.Count & Environment.NewLine
Console.WriteLine(s_msg)
Dim x509 As X509Certificate2
For Each x509 In scollection
Dim dname As New X500DistinguishedName(
x509.SubjectName.Name,
X500DistinguishedNameFlags.Reversed Or X500DistinguishedNameFlags.UseSemicolons
)
s_msg = "X500DistinguishedName: " & dname.Name & Environment.NewLine
Console.WriteLine(s_msg)
x509.Reset()
Next x509
store.Close()
Catch e As Exception
s_msg = "Error: Information could not be written out for this certificate."
Console.WriteLine(s_msg)
End Try
End Sub
End Class
Comentários
A classe X500DistinguishedName herda da classe AsnEncodedData.