Aracılığıyla paylaş


HttpListenerRequest.ClientCertificateError Özellik

Tanım

İstemci tarafından sağlanan ile X509Certificate ilgili bir sorunu tanımlayan bir hata kodu alır.

public:
 property int ClientCertificateError { int get(); };
public int ClientCertificateError { get; }
member this.ClientCertificateError : int
Public ReadOnly Property ClientCertificateError As Integer

Özellik Değeri

Int32 Windows hata kodu içeren bir değer.

Özel durumlar

İstemci sertifikası henüz veya GetClientCertificate() yöntemlerine BeginGetClientCertificate(AsyncCallback, Object) yapılan bir çağrıyla başlatılmadı

-Veya-

İşlem devam ediyor.

Örnekler

Aşağıdaki kod örneği, isteğin geçerli bir istemci sertifikası içerip içermediğini belirlemek için bu özelliği denetler.

Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count);
HttpListenerContext context = listener.GetContext();
HttpListenerRequest request = context.Request;
Console.WriteLine("Received a request.");
// This server requires a valid client certificate
// for requests that are not sent from the local computer.

// Did the client omit the certificate or send an invalid certificate?
if (request.IsAuthenticated &&
    request.GetClientCertificate() == null ||
    request.ClientCertificateError != 0)
{
    // Send a 403 response.
    HttpListenerResponse badCertificateResponse = context.Response ;
    SendBadCertificateResponse(badCertificateResponse);
    Console.WriteLine("Client has invalid certificate.");
    continue;
}
Console.WriteLine("Listening for {0} prefixes...", listener.Prefixes.Count)
Dim context As HttpListenerContext = listener.GetContext()
Dim request As HttpListenerRequest = context.Request
Console.WriteLine("Received a request.")
' This server requires a valid client certificate
' for requests that are not sent from the local computer.

' Did the client omit the certificate or send an invalid certificate?
If request.IsAuthenticated AndAlso request.GetClientCertificate() Is Nothing OrElse request.ClientCertificateError <> 0 Then
    ' Send a 403 response.
    Dim badCertificateResponse As HttpListenerResponse = context.Response
    SendBadCertificateResponse(badCertificateResponse)
    Console.WriteLine("Client has invalid certificate.")
    Continue Do
End If

Açıklamalar

Bu özellik, sertifikayı doğrulamak için kullanılan Güvenli Kanal (Schannel) Güvenlik Desteği Sağlayıcısı Arabirimi (SSPI) tarafından döndürülen bir Windows hata kodu içerir. Schannel için SSPI desteği hakkında daha fazla bilgi için bkz. Schannel Kullanarak Güvenli Bağlantı Oluşturma.

Şunlara uygulanır

Ayrıca bkz.