Java 通过OkHttpClient连接到API时发生TLS错误
尝试使用OkHttpClient连接到APi服务器时出错 对此充满了研究,并尝试了任何可能有帮助的选择 我正在与Eclipse合作 我的错误是“连接被对等方关闭”,我无法解决它,因此我下载了OkHttp的jar文件,然后我确定了错误:Java 通过OkHttpClient连接到API时发生TLS错误,java,android,okhttp3,Java,Android,Okhttp3,尝试使用OkHttpClient连接到APi服务器时出错 对此充满了研究,并尝试了任何可能有帮助的选择 我正在与Eclipse合作 我的错误是“连接被对等方关闭”,我无法解决它,因此我下载了OkHttp的jar文件,然后我确定了错误: Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], tlsVer
Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], tlsVersions=[TLS_1_2], supportsTlsExtensions=true)], supported protocols=[SSLv3, TLSv1]
有人能帮我设置ConnectionSecs吗?我想这是我的问题,不管我放在哪里,我放的东西都会出错
谢谢你调查我的问题,因为我迷路了
String r = "";
Response response;
try {
String url = "https://api.honeywell.com/oauth2/token";
RequestBody requestBody = new
MultipartBody.Builder().setType(MultipartBody.FORM)
.addFormDataPart("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML").build();
Request request = new Request.Builder().url(url).post(requestBody).build();
OkHttpClient client = new OkHttpClient();
ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).tlsVersions(TlsVersion.TLS_1_2)
.cipherSuites(CipherSuite.TLS_DHE_RSA_WITH_AES_256_CBC_SHA).build();
client = new OkHttpClient.Builder().connectionSpecs(Collections.singletonList(spec)).build();
try {
response = client.newCall(request).execute();
r = response.body().toString();
} catch (IOException e) {
r = "1111 " + e.getMessage();
}
} catch (Exception e) {
r = "222 " + e.getMessage();
}
return r;