Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用SSLContext将TLSv1更改为TLSv1.2时出现问题_Java_Ssl_Soap_Salesforce - Fatal编程技术网

Java 使用SSLContext将TLSv1更改为TLSv1.2时出现问题

Java 使用SSLContext将TLSv1更改为TLSv1.2时出现问题,java,ssl,soap,salesforce,Java,Ssl,Soap,Salesforce,我尝试使用SSLContext启用TLSv1.2,并尝试System.setProperty(“https.protocols”,“TLSv1.2”)。我想在我的应用程序中为salesforce soap API启用它。问题是,当我运行示例代码时,TLS版本是TLSv1,因此我使用我的代码并将其更改为TLSv1.2。我的示例代码 public static void tls(String tls){ SSLContext context; try { Sy

我尝试使用SSLContext启用TLSv1.2,并尝试System.setProperty(“https.protocols”,“TLSv1.2”)。我想在我的应用程序中为salesforce soap API启用它。问题是,当我运行示例代码时,TLS版本是TLSv1,因此我使用我的代码并将其更改为TLSv1.2。我的示例代码

 public static void tls(String tls){
    SSLContext context;

      try {
        System.out.println(SSLContext.getDefault().getProtocol());
        context = SSLContext.getInstance(tls);
        context.init(null, null, null);
        System.out.println(SSLContext.getDefault().getProtocol());
        System.setProperty("https.protocols", tls);
        SSLContext.setDefault(context);
        System.out.println(SSLContext.getDefault().getProtocol());
      } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
      }
}`
当我点击salesforce Soap API时,将TLSv1更改为TLSv1.2之后,它使用了TLSv1,salesforce拒绝了它,因为我在salesforce帐户上禁用了TLSv1。我的salesfoce连接代码

public static void login(){
    try {

         System.out.println("login()"+SSLContext.getDefault().getProtocol());
         String username = "userName";
         String password = "pass";
         String authEndPoint = "https://login.salesforce.com/services/Soap/u/8.0/";
         SoapBindingStub binding = null;
         binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
         binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, authEndPoint);
         LoginResult rs = null;
         rs = binding.login(username, password);
         GetUserInfoResult userInfo =rs.getUserInfo();
         binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, rs.getServerUrl());
         } catch (RemoteException e) {
            System.out.println(e.getMessage());
         } catch (Exception e) {
            e.printStackTrace();
         }
}
我的Salesforce帐户登录活动日志

失败:通过不安全的channel-SOAP-Partner-8.0-Login.salesforce.com-TLS 1.0登录


我尝试了在谷歌上找到的每一件事,但问题仍然是一样的。请帮我解决此问题。

您最好将此信息发布到专门的salesforce stackexchange()上。不管怎样,您找到解决此问题的方法了吗?在SFDC示例中,它们通常连接到较新的API。如果将8.0更改为例如32.0,会发生什么情况?我用代码对此进行了测试,但仍然存在相同的错误。我还没有找到解决此问题的方法