[ Android ] 앱의 WebView SSL 오류 핸들러 알림 해결 방법
2019. 12. 9. 12:11ㆍAndroid
728x90
반응형
SMALL
웹뷰를 구현할 때 코드상에서 onReceivedSslError 함수를 구현하여 SSL 오류를 무시할 때 코드는 다음과 같습니다.
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error){
handler.proceed();
}
이렇게 구현하면 작동은 하지만 Play Console에 앱을 출시하면 경고가 뜨게 됩니다.
그러므로 상황에 따라 handler.proceed()를 호출하거나, handler.cancel()을 호출하도록 구현해야 합니다.
간단한 방법으로는 웹브라우저에서처럼 사용자에게 결정을 맡기도록 구현하는 방법인데 다음과 같습니다.
@Override
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("이 사이트의 보안 인증서는 신뢰하는 보안 인증서가 아닙니다. 계속하시겠습니까?");
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();
}
});
final AlertDialog dialog = builder.create();
dialog.show();
}
이렇게 구현하면 Play Console 상에서 보안 경고가 사라지게 됩니다.
728x90
반응형
'Android' 카테고리의 다른 글
[ Android ] 안드로이드 웹뷰 net::ERR_CACHE_MISS 해결 방법 (0) | 2019.12.23 |
---|---|
[ Android ] 안드로이드 권한 처리하기 (0) | 2019.12.23 |
[ Android ] a webview method was called on thread 'javabridge' (0) | 2019.12.19 |
[ Android ] 자바스크립트 인터페이스 삽입 취약점 문제 해결 하기 (0) | 2019.12.06 |
[ Android ] 버전을 출시하지 못했습니다. 페이지에 유효성 검사 오류가 있는지 확인하세요. (0) | 2019.12.05 |