语言

StreamWebSocketControl.IgnorableServerCertificateErrors 属性

定义

获取可忽略服务器证书错误的列表。 获取此列表,并为希望在安全 WebSocket(wss:// 协议)服务器证书验证过程中忽略的服务器证书错误添加 ChainValidationResult 值。

public:
 property IVector<ChainValidationResult> ^ IgnorableServerCertificateErrors { IVector<ChainValidationResult> ^ get(); };
IVector<ChainValidationResult> IgnorableServerCertificateErrors();
public IList<ChainValidationResult> IgnorableServerCertificateErrors { get; }
var iVector = streamWebSocketControl.ignorableServerCertificateErrors;
Public ReadOnly Property IgnorableServerCertificateErrors As IList(Of ChainValidationResult)

属性值

ChainValidationResult 值的列表,指示验证服务器证书时要忽略的服务器证书错误。 默认情况下,列表为空,所有错误都会导致验证失败。

实现

Windows 要求

要求 说明
设备系列
Windows 10 Anniversary Edition (在 10.0.14393.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v3.0 中引入)

示例

以下示例演示如何在连接到使用自签名证书的服务器时忽略 ChainValidationResult.Untrusted 错误。 在 Web 套接字上调用 ConnectAsync 之前,代码会将相应的值添加到 IgnorableServerCertificateErrors 列表。 服务器的自签名证书不会导致验证失败,但验证服务器证书的其他错误仍会导致 ConnectAsync 失败。

private async void CreateAndConnectWebSocket()
{
    var myWebSocket = new StreamWebSocket();
    myWebSocket.Information.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);

    ...

    await myWebSocket.ConnectAsync(new Uri("wss://contoso.com/wsendpoint1"));

}

适用于