SSLHandshakeException: SSL handshake aborted: ssl=0xbe6af938: I/O error during system call, Connection reset by peer

huangapple go评论81阅读模式
英文:

SSLHandshakeException: SSL handshake aborted: ssl=0xbe6af938: I/O error during system call, Connection reset by peer

问题

以下是翻译好的部分:

以下错误发生:javax.net.ssl.SSLHandshakeException: SSL握手中止:ssl=0xbe6af938:系统调用期间的I/O错误,对等方重置连接

Retrofit类:

public class RetrofitClientInstance {
    
    private static Retrofit retrofit;

    public static Retrofit getRetrofitInstance() {
        
        if (retrofit == null) {
            Gson gson = new GsonBuilder().setLenient().create();

            retrofit = new retrofit2.Retrofit.Builder()
                    .client(HelperOkHttpClient.getOkHttpClient())
                    .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                    .baseUrl(BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create(gson))
                    .build();
        }
        return retrofit;
    }
}

该错误/异常出现在以下方法中:

private void makeRequestToSecondAuthStep(ArrayList<String> creds) {

    AuthCheckHTTP defectSpecific = RetrofitClientInstance.getRetrofitInstance().create(AuthCheckHTTP.class);
    Observable<ResponseSingleRequestAuth<Object>> observableDefectsRelated = defectSpecific.getAuthCheck();
    observableDefectsRelated
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .doOnNext(specficDefects -> {
                Log.w("ASYNCLI", "In defectspecif");
                if (HelperIsNull.isNull(creds.get(3))) {
                    creds.set(3, creds.get(5));
                }
                DataBaseHelper.deleteAllData();
                PublisherNotificationSync.getInstance().setLastSyncDate(INITIAL_DATE);
                writeCredentialsToLocalDb();

                actMain.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        presenterAuthAct.downloadData();
                    }
                });
            })
            .doOnError(
                    throwable -> {
                        HelperToastMaker.createMessage(App.getAppContext(), "Your user does not have permission to use the mobile application");
                        ((Button) mainAct.findViewById(R.id.button)).setEnabled(true);
                        AppProperties.setpIdentificator("");
                    }
            ).doOnComplete(() -> {
        Log.w("Event", "Fired i guess");
    }).subscribe(new Observer<ResponseSingleRequestAuth<Object>>() {
        @Override
        public void onSubscribe(Disposable d) {

        }

        @Override
        public void onNext(ResponseSingleRequestAuth<Object> objectResponseSingleRequestAuth) {

        }

        @Override
        public void onError(Throwable e) {
          // do nothing
        }

        @Override
        public void onComplete() {

        }
    });

}

也许您可以在这个Retrofit类中添加标准(SSL),是否有人之前遇到过这个或类似的问题?

问题可能是什么?几个月前一切正常,项目没有被触碰过(已归档)。

提前谢谢您

更新:与证书无关,这是SAP,它们自行更新。

英文:

The following error occurs: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0xbe6af938: I/O error during system call, Connection reset by peer

Retrofit class:

public class RetrofitClientInstance {
private static Retrofit retrofit;
public static Retrofit getRetrofitInstance() {
if (retrofit == null) {
Gson gson = new GsonBuilder().setLenient().create();
retrofit = new retrofit2.Retrofit.Builder()
.client(HelperOkHttpClient.getOkHttpClient())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
}
return retrofit;
}
}

The error / exception appears in this method:

private void makeRequestToSecondAuthStep(ArrayList&lt;String&gt; creds) {
AuthCheckHTTP defectSpecific = RetrofitClientInstance.getRetrofitInstance().create(AuthCheckHTTP.class);
Observable&lt;ResponseSingleRequestAuth&lt;Object&gt;&gt; observableDefectsRelated = defectSpecific.getAuthCheck();
observableDefectsRelated
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(specficDefects -&gt; {
Log.w(&quot;ASYNCLI&quot;, &quot;In defectspecif&quot;);
if (HelperIsNull.isNull(creds.get(3))) {
creds.set(3, creds.get(5));
}
DataBaseHelper.deleteAllData();
PublisherNotificationSync.getInstance().setLastSyncDate(INITIAL_DATE);
writeCredentialsToLocalDb();
actMain.runOnUiThread(new Runnable() {
@Override
public void run() {
presenterAuthAct.downloadData();
}
}
);
})
.doOnError(
throwable -&gt; {
HelperToastMaker.createMessage(App.getAppContext(), &quot;У вашего пользователя нет прав на пользования мобильным приложением&quot;);
((Button) mainAct.findViewById(R.id.button)).setEnabled(true);
AppProperties.setpIdentificator(&quot;&quot;);
}
).doOnComplete(() -&gt; {
Log.w(&quot;Event&quot;, &quot;Fired i guess&quot;);
}).subscribe(new Observer&lt;ResponseSingleRequestAuth&lt;Object&gt;&gt;() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(ResponseSingleRequestAuth&lt;Object&gt; objectResponseSingleRequestAuth) {
}
@Override
public void onError(Throwable e) {
// do nothing
}
@Override
public void onComplete() {
}
});
}
}

Maybe somehow you can add standards (SSL) to this Retrofit class, could anyone have encountered this or a similar problem before?

What could be the problem? A few months ago - everything worked, the project was not touched (archived)
Thank you in advance

UPD: nothing to do with the certificate, this is SAP, they update themselves

答案1

得分: 2

抱歉,您提供的内容中包含代码部分,根据您的要求,我只能返回翻译好的部分,不包括代码部分。以下是您提供内容的翻译:

我不确定这里是否有足够的信息让我能够准确地诊断您的问题,但错误表明存在SSL握手错误,对我来说,这通常表示问题不在代码中,而是在用于通信通道的证书/可接受加密算法中。

Retrofit是一个REST框架,所以我假设您在其之上编写了一个API,而Retrofit处理您的HTTP会话和SSL相关事务。您说解决方案突然停止工作了。您的Retrofit依赖是否是最新的?也许可以更新依赖项,重新打包您的应用程序,然后查看是否有效?

Retrofit/OkHTTP带有TLS上下文的示例

英文:

I'm not sure there's enough info here for me to accurately diagnose your problem but the error indicates an SSL handshake error, which would normally, to me, indicate the problem isn't in the code, but in the certs/acceptable encryption algorithms for the communication channel.

Retrofit is a REST framework, so I'm assuming you wrote an API on top of it and retrofit handles your HTTP sessions and SSL stuff. You said the solution suddenly stopped working. Is your retrofit dependency up to date? Maybe bring your dependencies up to date, repackage your application and see if that works?

Retrofit/OkHTTP examples with TLS Context

huangapple
  • 本文由 发表于 2020年9月15日 01:45:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/63889349.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定