Android 改装-SSL库中出现故障,通常是协议错误
我一直试图使用改型向服务器发出请求,但它一直给我这个错误Android 改装-SSL库中出现故障,通常是协议错误,android,ssl,retrofit,okhttp,Android,Ssl,Retrofit,Okhttp,我一直试图使用改型向服务器发出请求,但它一直给我这个错误 javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x60cc49f8: Failure in SSL library, usually a protocol error 这段代码一直有效到现在,我没有碰任何东西,也没有更改任何东西,我想知道库发生了什么 见下文: String BASE_URL = "https://api.example.com"; Ret
javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x60cc49f8: Failure in SSL library, usually a protocol error
这段代码一直有效到现在,我没有碰任何东西,也没有更改任何东西,我想知道库发生了什么
见下文:
String BASE_URL = "https://api.example.com";
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
PayInterface service = retrofit.create(PayInterface.class);
Call<PaymentData> call = service.getPost();
call.enqueue(new Callback<PaymentData>() {
@Override
public void onResponse(Response<PaymentData> response, Retrofit retrofit) {
// Get result Repo from response.body()
// response.isSuccess() is true if the response code is 2xx
int statusCode = response.code();
if (response.isSuccess()) {
PaymentData post = response.body();
System.out.println("my post: "+post.getMessage());
} else {
// handle request errors yourself
ResponseBody errorBody = response.errorBody();
}
}
@Override
public void onFailure(Throwable t) {
System.out.println("failed: "+t);
}
});
请问,我缺少什么吗?您的主机服务器支持哪些SSL/TLS协议?你最近更新过你的android操作系统版本吗?您设备的SSL提供程序库是否最新?您不能在okhttp 3.3上操作有什么原因吗?
public interface PayInterface {
@Headers({
"Key1: xxx",
"Content-Type: application/json",
"User-Agent: My-App-Name"
})
@POST("/path/another-path")
Call<PaymentData>
getPost();
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.code.gson:gson:2.4'
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
compile 'com.squareup.okhttp:okhttp:2.7.0'
}