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

关闭 TLS 1.0 和 1.1

如何解决关闭 TLS 1.0 和 1.1

我正在开发 Windows 应用程序(WPF、WCF 和 XAML 等)。还有一个用 VB6(Web 类)设计的遗留 Web 应用程序。该应用程序使用框架 4.0,但有些已升级到 4.5。简而言之,所有这些都有些遗留。

客户要求关闭 TLS 1.0 和 1.1。 在更改注册表以关闭上述功能后,我收到一个错误 - “调用者未通过服务进行身份验证。”在 WPF 应用中。

登录获取Token的代码如下:

  private SecurityToken GetToken(string username,string password)
  {
     try
     {
        var stsEndpointAddress = EndpointAddressAccess.GetEndpointAddress(ShellState.NimbusSecurityTokenServerConfiguration.BindingProfile,ShellState.NimbusSecurityTokenServerConfiguration.Address);
        var stsBinding = BindingAccess.GetBinding(ShellState.NimbusSecurityTokenServerConfiguration.BindingProfile);

        var tokenClient = new WSTrustChannelFactory(stsBinding,stsEndpointAddress);

        tokenClient.Credentials.UserName.UserName = username;
        tokenClient.Credentials.UserName.Password = password;

        tokenClient.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; // Todo - fix (profile value - lite or secure)

        tokenClient.TrustVersion = TrustVersion.WSTrust13;
        tokenClient.open();
        // mat_mac 0 Keep the line below : .NET 4.5 version of this code
        //var rst = new RequestSecurityToken(RequestTypes.Issue)
        var rst = new RequestSecurityToken(WSTrust13Constants.RequestTypes.Issue)
        {
           //// Todo - remove or modify this audience section -- coordinate with other settings around Audience and whether it's checked
           // Note - can't just remove this.  Need to set some alternative properties (I think) to state that the audience isn't being validated
           // Without this line the WCF call fails with some obscure errors
           //AppliesTo = new EndpointReference("net.tcp://localhost:9876/AuthenticationWcf")
           //AppliesTo = new EndpointReference("urn://dummy")  // <<----- .NET4.5 Version of this code 
           AppliesTo = new EndpointAddress("urn://dummy")
        };
        var chn = tokenClient.CreateChannel();
        return chn.Issue(rst);
     }
     catch (System.ServiceModel.Security.MessageSecurityException)
     {
        _log.Error("GetToken caught MessageSecurityException");
        return null;
     }
     catch (Exception ex)
     {
        _log.ErrorException("GetToken threw exception",ex);
        return null;
     }
  }

错误显然是作为异常返回 - “GetToken throwed exception”(上图)

如果有人可以提供帮助,我将不胜感激?谢谢和亲切的问候。

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

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?