Java 8 致命警报:Java 8上的协议版本

Java 8 致命警报:Java 8上的协议版本,java-8,http-post,httpclient,Java 8,Http Post,Httpclient,我有一个用Java8开发的webservice客户端。我已经通过此站点验证了我连接的主机正在使用TLSv1.2 我在发送和执行post请求时遇到以下错误: javax.net.ssl.SSLException:收到致命警报:协议\u版本 我在代码的开头添加了这一行。不走运 System.setProperty(“https.protocols”、“TLSv1.2”) 我还在WebSphereServer应用程序中添加了一个JVM参数 -Dhttps.protocols=TLSv1.2 尽管如此,

我有一个用Java8开发的webservice客户端。我已经通过此站点验证了我连接的主机正在使用TLSv1.2

我在发送和执行post请求时遇到以下错误:

javax.net.ssl.SSLException:收到致命警报:协议\u版本

我在代码的开头添加了这一行。不走运

System.setProperty(“https.protocols”、“TLSv1.2”)

我还在WebSphereServer应用程序中添加了一个JVM参数

-Dhttps.protocols=TLSv1.2

尽管如此,错误仍然存在

我读过类似的问题,我认为使用Java8默认为TLSv1.2。 错误不断出现,所以我仍然添加了这些属性。 所以我不知道为什么会这样

这是我的密码

Loggers.general().debug(LOG, "### getOKTAToken()...");
String OKTAresponse = "";
OKTAResponse oktaReply = new OKTAResponse();
HttpClient httpClient = HttpClientBuilder.create().build();
Loggers.general().debug(LOG, "### ipsum");
//pass webservice URL
Loggers.general().debug(LOG, "URL:{}",Constants.URL);
HttpPost httpPost = new HttpPost(Constants.URL);        
ArrayList<NameValuePair> postParameters;

//required keys for OKTA call
Loggers.general().debug(LOG, "Setting Body");
postParameters = new ArrayList<NameValuePair>();
postParameters.add(new BasicNameValuePair("client_id", 
Constants.clientID));
postParameters.add(new BasicNameValuePair("client_secret", 
Constants.clientSecret));
postParameters.add(new BasicNameValuePair("grant_type", 
Constants.grantType));

try 
{
Loggers.general().debug(LOG, "Setting entity...");
httpPost.setEntity(new UrlEncodedFormEntity(postParameters,"UTF-8"));
HttpResponse response = httpClient.execute(httpPost);
Loggers.general().debug(LOG,“######getOKTAToken()…”;
字符串OktarResponse=“”;
OktarResponse oktaReply=新OktarResponse();
HttpClient HttpClient=HttpClientBuilder.create().build();
Loggers.general().debug(LOG,“####ipsum”);
//传递Web服务URL
调试(LOG,“URL:{}”,Constants.URL);
HttpPost-HttpPost=新的HttpPost(Constants.URL);
ArrayList后参数;
//OKTA呼叫所需的密钥
调试(日志,“设置主体”);
postParameters=新的ArrayList();
添加(新的BasicNameValuePair(“客户端id”),
常量(clientID));
添加(新的BasicNameValuePair(“客户机密”),
常量(clientSecret);
添加(新的BasicNameValuePair(“授权类型”),
常量(grantType));
尝试
{
调试(记录“设置实体…”);
setEntity(新的UrlEncodedFormEntity(后参数,“UTF-8”);
HttpResponse response=httpClient.execute(httpPost);
错误指向最后一行。 HttpResponse response=httpClient.execute(httpPost); 有人知道为什么这个错误不断出现吗?需要增援

环境:

  • 爪哇8
  • WebSphere 8.5.5
  • 视窗10

您必须在Websphere Application Server级别更改TLS协议版本,而不是在Java运行时执行期间

如下面的屏幕截图所示,从WAS管理控制台将协议设置为TLSv1.2,然后重新启动Websphere应用程序服务器


您必须在Websphere Application Server级别更改TLS协议版本,而不是在Java运行时执行期间

如下面的屏幕截图所示,从WAS管理控制台将协议设置为TLSv1.2,然后重新启动Websphere应用程序服务器