验证失败,因为远程方已关闭传输流 [英] Authentication failed because the remote party has closed the transport stream
问题描述
这发生在 sslStream.AuthenticateAsServer(serverCertificate,
真的,SslProtocols.Default,真实);
呼叫。
我试图做客户端的认证方式。我同时控制客户端和服务器,两者都是C#通过sslstream。
当我使用一个服务器的NodeJS,它完美的作品。但是,我只是无法获得服务器端可靠地在C#中工作,出于某种原因。显然,SSL认证方式需要等待客户端选择客户端证书,但显然这不是一个内置的功能对于C#sslstream类?
我已经尝试过呼叫之前这样做,但它仍然立即的在电话会议上出现了错误:
我不介意在IE的安全问题。没关系。我担心的事实sslstream似乎并不怎么用这样一个基本SZENARIO在所有的工作。
从WCF跟踪错误:
System.Net错误:0:[7928]中的AppDomain#13869071 :: UnhandledExceptionHandler例外 - 验证失败,因为远程方已关闭传输流..
在System.Net.Security.SslState.ValidateCreateContext(布尔isServer,字符串targetHost,SslProtocols enabledSslProtocols,X509证书serverCertificate,X509CertificateCollection clientCertificates,布尔remoteCertRequired,布尔checkCertRevocationStatus,布尔checkCertName)
在System.Net.Security.SslStream.AuthenticateAsServer(X509证书serverCertificate,布尔clientCertificateRequired,SslProtocols enabledSslProtocols,布尔checkCertificateRevocation)
块引用>解决方案添加低于code帮助我克服这个问题(我跑在.NET 4.5.1应用程序)。
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
This happens on the
sslStream.AuthenticateAsServer(serverCertificate, true, SslProtocols.Default, true);
call.I'm trying to do client authentification. I control both client and server, both are c# via sslstream. When I use a nodejs server, it works perfectly. But I just cant get the serverside to reliably work in c# for some reason. Clearly the ssl authentification needs to wait for the client to choose the client certificate, but apparently this is not a built in feature for c# sslstream class? I already tried doing this before the call, but it still immediately errors out on the call:
I dont mind the security question in IE. That's fine. I'm concerned with the fact how sslstream does not seem to work at all with such a basic szenario.
Error from wcf trace:
System.Net Error: 0 : [7928] Exception in AppDomain#13869071::UnhandledExceptionHandler - Authentication failed because the remote party has closed the transport stream.. at System.Net.Security.SslState.ValidateCreateContext(Boolean isServer, String targetHost, SslProtocols enabledSslProtocols, X509Certificate serverCertificate, X509CertificateCollection clientCertificates, Boolean remoteCertRequired, Boolean checkCertRevocationStatus, Boolean checkCertName) at System.Net.Security.SslStream.AuthenticateAsServer(X509Certificate serverCertificate, Boolean clientCertificateRequired, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
解决方案Adding the below code helped me overcome the issue (I'm running the app in .NET 4.5.1).
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11;
这篇关于验证失败,因为远程方已关闭传输流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!