我已经研究了如何建立从WP8.1到远程主机(在本例中是ELK安全系统网络接口)的TCP / SSL连接。
我找到了一些示例,可以通过连接,捕获失败,然后设置IgnorableServerCertificateErrors集合来忽略某些证书错误。
但是,当我连接到我的ELK安全网络接口时,我总是收到错误
{System.Exception:无法验证证书的签名。 (HRESULT的例外情况:0x80096004)
,标记为致命,不可忽略。
我一直与运行ELK安全网络接口的代码的开发人员联系,了解他们的SSL实现。
他说“证书是自签名的,仅用于共享密钥来加密数据,而不是身份证明。如果ELK要这样做,那么每个XEP对于其中唯一的CA签名证书将花费更多。您应该尝试覆盖证书处理例程以接受XEP发送的任何证书。但是,在证书标题中,您应该看到单词“Elk”和“M1XEP”您可以查找它以确认它是XEP证书。“
所以基本上我知道证书无法验证,但我还是要忽略它并连接。
有没有人有任何建议?我的应用程序没用,直到我能够通过它。 谢谢! 克里斯
代码,如果你想看到它:
try
{
await socket.ConnectAsync(hostName, Port.ToString(), SocketProtectionLevel.Ssl);
return false;
}
catch (Exception exception)
{
// If this is an unknown status it means that the error is fatal and retry will likely fail.
if (SocketError.GetStatus(exception.HResult) == SocketErrorStatus.Unknown)
{
UpdateSubLine("con-Error");
return false;
}
// If the exception was caused by an SSL error that is ignorable we are going to prompt the user
// with an enumeration of the errors and ask for permission to ignore.
//
if (socket.Information.ServerCertificateErrorSeverity != SocketSslErrorSeverity.Ignorable)
{
UpdateSubLine("con-Fatal");
return false;
}
}
socket.Control.IgnorableServerCertificateErrors.Clear();
foreach (var ignorableError in socket.Information.ServerCertificateErrors)
{
socket.Control.IgnorableServerCertificateErrors.Add(ignorableError);
}
return true;