Compartir a través de


X509Chain.Build(X509Certificate2) Método

Definición

Compila una cadena X.509 usando la directiva especificada en X509ChainPolicy.

public:
 bool Build(System::Security::Cryptography::X509Certificates::X509Certificate2 ^ certificate);
public bool Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public bool Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate);
member this.Build : System.Security.Cryptography.X509Certificates.X509Certificate2 -> bool
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Build : System.Security.Cryptography.X509Certificates.X509Certificate2 -> bool
Public Function Build (certificate As X509Certificate2) As Boolean

Parámetros

certificate
X509Certificate2

Un objeto X509Certificate2.

Devoluciones

Boolean

Es true si el certificado X.509 es válido; en caso contrario, es false.

Atributos

Excepciones

certificate no es un certificado válido o es null.

certificate no se puede leer.

Ejemplos

En el ejemplo de código siguiente se abre el almacén de certificados personal del usuario actual, se puede seleccionar un certificado y, a continuación, se escribe información sobre el certificado y la cadena de certificados en la consola. La salida depende del certificado que seleccione.

//Output chain information of the selected certificate.
X509Chain ^ ch = gcnew X509Chain;
ch->ChainPolicy->RevocationMode = X509RevocationMode::Online;
ch->Build( certificate );
Console::WriteLine( "Chain Information" );
Console::WriteLine( "Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag );
Console::WriteLine( "Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode );
Console::WriteLine( "Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags );
Console::WriteLine( "Chain verification time: {0}", ch->ChainPolicy->VerificationTime );
Console::WriteLine( "Chain status length: {0}", ch->ChainStatus->Length );
Console::WriteLine( "Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count );
Console::WriteLine( "Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine );
//Output chain information of the selected certificate.
X509Chain ch = new X509Chain();
ch.ChainPolicy.RevocationMode = X509RevocationMode.Online;
ch.Build (certificate);
Console.WriteLine ("Chain Information");
Console.WriteLine ("Chain revocation flag: {0}", ch.ChainPolicy.RevocationFlag);
Console.WriteLine ("Chain revocation mode: {0}", ch.ChainPolicy.RevocationMode);
Console.WriteLine ("Chain verification flag: {0}", ch.ChainPolicy.VerificationFlags);
Console.WriteLine ("Chain verification time: {0}", ch.ChainPolicy.VerificationTime);
Console.WriteLine ("Chain status length: {0}", ch.ChainStatus.Length);
Console.WriteLine ("Chain application policy count: {0}", ch.ChainPolicy.ApplicationPolicy.Count);
Console.WriteLine ("Chain certificate policy count: {0} {1}", ch.ChainPolicy.CertificatePolicy.Count, Environment.NewLine);
'Output chain information of the selected certificate.
Dim ch As New X509Chain()
ch.ChainPolicy.RevocationMode = X509RevocationMode.Online
ch.Build(certificate)
Console.WriteLine("Chain Information")
Console.WriteLine("Chain revocation flag: {0}", ch.ChainPolicy.RevocationFlag)
Console.WriteLine("Chain revocation mode: {0}", ch.ChainPolicy.RevocationMode)
Console.WriteLine("Chain verification flag: {0}", ch.ChainPolicy.VerificationFlags)
Console.WriteLine("Chain verification time: {0}", ch.ChainPolicy.VerificationTime)
Console.WriteLine("Chain status length: {0}", ch.ChainStatus.Length)
Console.WriteLine("Chain application policy count: {0}", ch.ChainPolicy.ApplicationPolicy.Count)
Console.WriteLine("Chain certificate policy count: {0} {1}", ch.ChainPolicy.CertificatePolicy.Count, Environment.NewLine)

Comentarios

Tenga en cuenta que un certificado X.509 válido de un emisor de confianza solo es válido para el uso especificado en el X509ChainPolicy objeto . Los certificados que cumplen estas reglas de directiva de cadena podrían no ser válidos para usos específicos con características como Security/MIME (SMIME), Authenticode o Secure Sockets Layer (SSL). Si se requiere un procesamiento adicional para determinar si el certificado es válido para una directiva específica, derive una clase de X509Chain e invalide el Build método para que llame primero al método de clase Build base y, a continuación, realice el procesamiento adicional.

Se aplica a