본문 바로가기
모바일/Android

앱의 WebView SSL 오류 핸들러 알림 해결 방법

by 죠부니 2018. 7. 24.
반응형

1. 원인

앱이 내려감

2. 확인

앱의 WebView SSL 오류 핸들러 알림 해결 방법

https://support.google.com/faqs/answer/7071387

3.검색



4. 결과

위의 블로그의 해결책에 따라 앱에 적용

SslAlerDialog.java 생성


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.webkit.SslErrorHandler;


public class SslAlertDialog {
private SslErrorHandler handler = null;
private AlertDialog dialog = null;

public SslAlertDialog(SslErrorHandler errorHandler, Activity activity) {

if (errorHandler == null || activity == null) return;

this.handler = errorHandler;

AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setMessage("ssl 인증서가 올바르지 않습니다. 계속 진행하시겠습니까?");
builder.setPositiveButton("확인", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.proceed();
}
});
builder.setNegativeButton("취소", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.cancel();
}
});

dialog = builder.create();
}

public void show() {
dialog.show();
}
}


@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
Logger.error("onReceivedSslError 발생");
SslAlertDialog dialog = new SslAlertDialog(handler, WebAcitivity.this);
dialog.show();
}



반응형