HttpClient =new DefaultHttpClient();
HttpPost post = new HttpPost("https://myulr/token");
post.addHeader("Content-Type", "application/x-www-form-urlencoded");
List<BasicNameValuePair> parametersBody = new ArrayList<BasicNameValuePair>();
parametersBody.add(new BasicNameValuePair("client_id","my-client-id"));
parametersBody.add(new BasicNameValuePair("client_secret","my-secret-key"));
parametersBody.add(new BasicNameValuePair("scope","my-scope"));
parametersBody.add(new BasicNameValuePair("grant_type","client_credentials"));
try{
post.setEntity(new UrlEncodedFormEntity(parametersBody));
HttpResponse httpResponse = httpClient.execute(post);
int code = httpResponse.getStatusLine().getStatusCode();
System.out.println("Code::::: "+code);
String result=EntityUtils.toString(httpResponse.getEntity());
System.out.println("Result: "+result);
}catch(Exception e){
e.printStackTrace();
}
에이 코드는 제대로 JDK8에서 실행되지하지만 JDK7에서 그것을 실행하려고하면, 그것은 javax.net.ssl.SSLPeerUnverifiedException을 던지고있다 : 피어 인증되지 않은 예외입니다. 나는 문제를 Google에 시도했다. X509TrustManager 및 X509HostnameVerifier를 작성할 수 있다는 것을 알았습니다. 나는 이러한 구현을 시도했지만 여전히 작동하지 않았다. 어떻게 JDK7에서 실행할 수 있는지 제안 해주십시오. 첫째 JDK 7에 출연 TLS 1.2 지원 -javax.net.ssl.SSLPeerUnverifiedException : jdk7에 인증되지 피어하지만 jdk8
가