微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

c# – 限制除TLS 1.2 serverside WCF之外的任何东西

我有一个简单的问题,但在任何地方找不到答案.
我有一个WCF服务器应用程序.我希望它只能使用TLS1.2.

我无法控制客户端,无法编辑机器上的SCHANNEL设置.

我已经尝试了以下内容,这似乎只适用于传出连接(客户端)

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

有没有办法限制任何东西,但TLS 1.2服务器每个代码

编辑:
我正在使用net.tcp绑定并创建这样的绑定:

private static Binding CreateNetTcpBinding()
    {
        return new NetTcpBinding
        {
            ReceiveTimeout = TimeSpan.FromMinutes(10),ReliableSession =
            {
                Enabled = true,InactivityTimeout = TimeSpan.FromMinutes(1)
            },Security =
            {
                Mode = SecurityMode.Transport,Transport =
                {
                    ClientCredentialType = TcpClientCredentialType.Windows,ProtectionLevel = ProtectionLevel.EncryptAndSign,SslProtocols = SslProtocols.Tls12
                },Message =
                {
                    AlgorithmSuite = SecurityAlgorithmSuite.xxx <-- not here on purpose,ClientCredentialType = MessageCredentialType.Windows
                }
            }
        };
    }

如果有人可以告诉我在哪里检查当前连接的TLS版本(某些上下文),这也是足够的!

先谢谢你!

解决方法

您是否尝试使用ServicePointManager.ServerCertificateValidationCallback.This回调让您有机会自己验证服务器证书.例如:
ServicePointManager.ServerCertificateValidationCallback = MyCertHandler; 
    ... 
static bool MyCertHandler(object sender,X509Certificate certificate,X509Chain chain,SslPolicyErrors error) 
{
     //Your logic here for certificate validation 
}

原文地址:https://www.jb51.cc/csharp/93506.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐