处理证书时发生未知错误 [英] An unknown error occurred while processing the certificate

查看:89
本文介绍了处理证书时发生未知错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自签名证书,我想在我的 websockets 服务器上使用它来处理来自 wss://localhost:443 的请求.我从任何网络浏览器连接到服务器.

但是,我似乎无法正确进行身份验证.每次我尝试通过 Advanced Rest Client (ARC) 软件连接到 WebSockets 服务器时,我都会输入 wss://localhost:443wss://127.0.0.1:443>、

出现异常

System.Security.Authentication.AuthenticationException:对 SSPI 的调用失败,请参阅内部异常.---> System.ComponentModel.Win32Exception:处理证书时发生未知错误".

我使用 openssl for windows 创建了证书,并创建了一个非常简单的证书.我仍然无法正确进行身份验证.有什么帮助吗?

这是我如何尝试使用 C# 代码进行操作

<预><代码>var serverCertificate = new X509Certificate2("E:\\TestsFolder\\test-cert.pfx", "12345");var 证书 = 新 X509CertificateCollection { serverCertificate };流流 = tcpClient.GetStream();SslStream sslStream = new SslStream(stream, false,(o, x509Certificate, chain, errors) =>真的,(o, s, collection, x509Certificate, issuers) =>证书[0]);等待 sslStream.AuthenticateAsServerAsync(serverCertificate, false, SslProtocols.Tls12, false);WebSocketHttpContext context = await _webSocketServerFactory.ReadHttpHeaderFromStreamAsync(sslStream, source.Token);

我到底会错过什么?

这是我的控制台的一个镜头,例外

解决方案

我们使我们的 websockets 服务器使用 TLS 1.2.

手动添加:

ws.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

解决了这个问题.

I have a self-signed certificate and i would like to use it on my websockets server to handle requests from wss://localhost:443. I connect to the server from any web-browser.

However, i cant seem to get the authentication right. Everytime i try to connect to the WebSockets Server via Advanced Rest Client (ARC) software, i type wss://localhost:443 or wss://127.0.0.1:443,

Am getting the exception

"System.Security.Authentication.AuthenticationException: A call to SSPI failed, see inner exception. ---> System.ComponentModel.Win32Exception: An unknown error occurred while processing the certificate".

I created the certificate using openssl for windows and created a very simple certificate. Still i cant get the authentication right. Any help?

Here is how am trying to go about it with the C# code


var serverCertificate = new X509Certificate2("E:\\TestsFolder\\test-cert.pfx", "12345");
var certificates = new X509CertificateCollection { serverCertificate };

Stream stream = tcpClient.GetStream();

SslStream sslStream = new SslStream(stream, false,
                    (o, x509Certificate, chain, errors) => true,
                    (o, s, collection, x509Certificate, issuers) => certificates[0]);

await sslStream.AuthenticateAsServerAsync(serverCertificate, false, SslProtocols.Tls12, false);

WebSocketHttpContext context = await _webSocketServerFactory.ReadHttpHeaderFromStreamAsync(sslStream, source.Token);

What on earth could i be missing?

Here is a shot of my console with the exception

解决方案

We made our websockets server to use TLS 1.2.

Adding manually:

ws.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

solved the issue.

这篇关于处理证书时发生未知错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆