IWebSocketControl2.IgnorableServerCertificateErrors 屬性

定義

取得可忽略的伺服器憑證錯誤清單。 取得此清單,並針對您想要在安全 WebSocket (wss://通訊協定) 伺服器憑證驗證程式期間忽略的伺服器憑證錯誤新增ChainValidationResult值。

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

屬性值

ChainValidationResult值的清單,指出驗證伺服器憑證時要忽略的伺服器憑證錯誤。 根據預設,清單是空的,而且所有錯誤都會導致驗證失敗。

範例

下列範例示範當您連接到使用自我簽署憑證的伺服器時,如何忽略 ChainValidationResult.Untrusted 錯誤。 程式碼會在 Web 通訊端上呼叫 ConnectAsync 之前,將適當的值新增至 IgnorableServerCertificateErrors 清單。 伺服器的自我簽署憑證不會造成驗證失敗,但驗證伺服器憑證的其他錯誤仍會導致 ConnectAsync 失敗。

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

    // ...

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

適用於