2015-09-25 13 views
10

Nhận cảnh báo từ google play.Cảnh báo SSL từ google play

Làm cách nào tôi có thể xử lý "Lỗ hổng trình xử lý lỗi SSL" của việc triển khai không an toàn của trình xử lý WebViewClient.onReceivedSslError.

"Vui lòng giải quyết lỗ hổng này càng sớm càng tốt và tăng số phiên bản của APK đã nâng cấp. Để xử lý xác thực chứng chỉ SSL đúng cách, hãy thay đổi mã của bạn để gọi SslErrorHandler.proceed() bất cứ khi nào chứng chỉ được trình bày đáp ứng yêu cầu của bạn và gọi SslErrorHandler.cancel() nếu không. "

+0

Thông tin thêm về lỗ hổng tại đây: http://stanford.edu/~pcm2d/blog/ssl.html –

Trả lời

9

Tôi đã nhận được cảnh báo tương tự hôm nay và thông báo cho tôi biết vấn đề đến từ SDK của một trong các mạng quảng cáo của tôi (InMobi, tôi thực sự xem xét việc bỏ chúng vì chúng có nhiều gian lận, tự động chuyển hướng biểu ngữ, và bây giờ điều này ...):

com.inmobi.commons.analytics.iat.impl.net.AdTrackerWebViewLoader$MyWebViewClient

lớp bị ảnh hưởng trong trường hợp của bạn là gì? Nếu đó là một trong các lớp học của riêng bạn, bạn sẽ phải đọc kỹ thuật số documentation và sửa lỗi triển khai của bạn.

Nếu, như tôi, bạn chỉ là nạn nhân của một trong các thư viện bên ngoài của bạn, hãy liên hệ với nhà phát triển để yêu cầu họ cung cấp thư viện cố định (hoặc thả thư viện).

+1

Hey @Sebastien. Tôi đến từ đội InMobi. Bạn gặp lỗi SSL vì các thay đổi đối với cửa hàng Google Play mà không yêu cầu https. Chỉ cần tải xuống SDK mới nhất của chúng tôi và điều này sẽ ổn thôi :) – Sohan

+1

Tôi đồng ý với quảng cáo chuyển hướng tự động, gian lận. Có rất nhiều khiếu nại của người dùng và xếp hạng không tốt vì quảng cáo InMobi. –

+3

@Sohan, lỗi không phải do thay đổi đối với Cửa hàng Play. Điều này làm cho nó có vẻ như đó là lỗi của Google. SDK của bạn có lỗ hổng nghiêm trọng cho phép tấn công MitM trong đó, Google chỉ cảnh báo cho các nhà phát triển về vấn đề này. –

-5

Điều này có thể do thư viện của bên thứ ba được sử dụng trong ứng dụng của bạn, bao gồm ssl mở. Nó đã xảy ra trong trường hợp của tôi. Thư viện được Google nhắc đến trong cảnh báo. Tôi đã sử dụng lệnh grep sau với thư viện đó bao gồm

$ unzip -p YourApp.apk | strings | grep "OpenSSL" 

Lệnh này sẽ hiển thị nhật ký dài, nếu có vấn đề ssl mở do thư viện đó.

+com.android.org.conscrypt.OpenSSLSocketImpl 
7org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl 
OpenSSLDie 
DH_OpenSSL 
OpenSSL_add_all_ciphers 
OpenSSL_add_all_digests 
DSA_OpenSSL 
ECDSA_OpenSSL 
ECDH_OpenSSL 
UI_OpenSSL 
OpenSSL/%lx.%lx.%lx%s 
OpenSSL 1.0.1h 5 Jun 2014 
%s(%d): OpenSSL internal error, assertion failed: %s 
OpenSSL DH Method 
OpenSSL CMAC method 
OpenSSL HMAC method 
OpenSSL EC algorithm 
OpenSSL RSA method 
OpenSSL DSA method 
OpenSSL ECDSA method 
OpenSSL PKCS#3 DH method 
OpenSSL ECDH method 
You need to read the OpenSSL FAQ, http://www.openssl.org/support/faq.html 
OpenSSL default 
OpenSSL default user interface 
OpenSSL 'dlfcn' shared library method 
SSLv2 part of OpenSSL 1.0.1h 5 Jun 2014 
SSLv3 part of OpenSSL 1.0.1h 5 Jun 2014 
TLSv1 part of OpenSSL 1.0.1h 5 Jun 2014 
DTLSv1 part of OpenSSL 1.0.1h 5 Jun 2014 
MD4 part of OpenSSL 1.0.1h 5 Jun 2014 
MD5 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA1 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA-256 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA-512 part of OpenSSL 1.0.1h 5 Jun 2014 
DES part of OpenSSL 1.0.1h 5 Jun 2014 
libdes part of OpenSSL 1.0.1h 5 Jun 2014 
AES part of OpenSSL 1.0.1h 5 Jun 2014 
Big Number part of OpenSSL 1.0.1h 5 Jun 2014 
^RSA part of OpenSSL 1.0.1h 5 Jun 2014 
Diffie-Hellman part of OpenSSL 1.0.1h 5 Jun 2014 
Stack part of OpenSSL 1.0.1h 5 Jun 2014 
lhash part of OpenSSL 1.0.1h 5 Jun 2014 
EVP part of OpenSSL 1.0.1h 5 Jun 2014 
ASN.1 part of OpenSSL 1.0.1h 5 Jun 2014 
PEM part of OpenSSL 1.0.1h 5 Jun 2014 
X.509 part of OpenSSL 1.0.1h 5 Jun 2014 
RC2 part of OpenSSL 1.0.1h 5 Jun 2014 
IDEA part of OpenSSL 1.0.1h 5 Jun 2014 
CAMELLIA part of OpenSSL 1.0.1h 5 Jun 2014 
EDSA part of OpenSSL 1.0.1h 5 Jun 2014 
ECDSA part of OpenSSL 1.0.1h 5 Jun 2014 
ECDH part of OpenSSL 1.0.1h 5 Jun 2014 
RAND part of OpenSSL 1.0.1h 5 Jun 2014 
CONF part of OpenSSL 1.0.1h 5 Jun 2014 
CONF_def part of OpenSSL 1.0.1h 5 Jun 2014 
TXT_DB part of OpenSSL 1.0.1h 5 Jun 2014 
SHA part of OpenSSL 1.0.1h 5 Jun 2014 
RIPE-MD160 part of OpenSSL 1.0.1h 5 Jun 2014 
RC4 part of OpenSSL 1.0.1h 5 Jun 2014 
:Blowfish part of OpenSSL 1.0.1h 5 Jun 2014 
\CAST part of OpenSSL 1.0.1h 5 Jun 2014 
OpenSSLDie 
DH_OpenSSL 
OpenSSL_add_all_ciphers 
OpenSSL_add_all_digests 
DSA_OpenSSL 
ECDSA_OpenSSL 
ECDH_OpenSSL 
UI_OpenSSL 
%s(%d): OpenSSL internal error, assertion failed: %s 
You need to read the OpenSSL FAQ, http://www.openssl.org/support/faq.html 
OpenSSL default user interface 
OpenSSL 'dlfcn' shared library method 
OpenSSL/%lx.%lx.%lx%s 
OpenSSL 1.0.1h 5 Jun 2014 
OpenSSL DH Method 
OpenSSL CMAC method 
OpenSSL HMAC method 
OpenSSL EC algorithm 
OpenSSL RSA method 
OpenSSL DSA method 
OpenSSL ECDSA method 
OpenSSL PKCS#3 DH method 
OpenSSL ECDH method 
OpenSSL default 
SSLv2 part of OpenSSL 1.0.1h 5 Jun 2014 
SSLv3 part of OpenSSL 1.0.1h 5 Jun 2014 
TLSv1 part of OpenSSL 1.0.1h 5 Jun 2014 
DTLSv1 part of OpenSSL 1.0.1h 5 Jun 2014 
MD4 part of OpenSSL 1.0.1h 5 Jun 2014 
MD5 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA1 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA-256 part of OpenSSL 1.0.1h 5 Jun 2014 
SHA-512 part of OpenSSL 1.0.1h 5 Jun 2014 
DES part of OpenSSL 1.0.1h 5 Jun 2014 
libdes part of OpenSSL 1.0.1h 5 Jun 2014 
AES part of OpenSSL 1.0.1h 5 Jun 2014 
Big Number part of OpenSSL 1.0.1h 5 Jun 2014 
^RSA part of OpenSSL 1.0.1h 5 Jun 2014 
Diffie-Hellman part of OpenSSL 1.0.1h 5 Jun 2014 
Stack part of OpenSSL 1.0.1h 5 Jun 2014 
lhash part of OpenSSL 1.0.1h 5 Jun 2014 
EVP part of OpenSSL 1.0.1h 5 Jun 2014 
ASN.1 part of OpenSSL 1.0.1h 5 Jun 2014 
PEM part of OpenSSL 1.0.1h 5 Jun 2014 
X.509 part of OpenSSL 1.0.1h 5 Jun 2014 
RC2 part of OpenSSL 1.0.1h 5 Jun 2014 
IDEA part of OpenSSL 1.0.1h 5 Jun 2014 
DSA part of OpenSSL 1.0.1h 5 Jun 2014 
ECDSA part of OpenSSL 1.0.1h 5 Jun 2014 
ECDH part of OpenSSL 1.0.1h 5 Jun 2014 
RAND part of OpenSSL 1.0.1h 5 Jun 2014 
CONF part of OpenSSL 1.0.1h 5 Jun 2014 
CONF_def part of OpenSSL 1.0.1h 5 Jun 2014 
TXT_DB part of OpenSSL 1.0.1h 5 Jun 2014 
SHA part of OpenSSL 1.0.1h 5 Jun 2014 
RIPE-MD160 part of OpenSSL 1.0.1h 5 Jun 2014 
Blowfish part of OpenSSL 1.0.1h 5 Jun 2014 
\CAST part of OpenSSL 1.0.1h 5 Jun 2014 

Hãy thử cùng một lệnh, cho một gói ứng dụng khác, không có thư viện đó. Nó sẽ chỉ hiển thị hai dòng như sau

+com.android.org.conscrypt.OpenSSLSocketImpl 
7org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl 
+1

Các cuộc đàm phán cảnh báo về việc triển khai onReceivedSslError không an toàn. Điều này không liên quan gì đến OpenSSL. – Antimony

+0

Tôi xác nhận nhận xét @Antimony –

2

Trước tiên bạn phải kiểm tra xem bạn có sử dụng trình xử lý WebViewClient.onReceivedSslError đúng cách không.

Nếu bạn không sử dụng thư viện WebViewClient hoặc nếu bạn đã sử dụng đúng cách, sự cố có thể đến từ thư viện của bên thứ ba. Trước tiên, bạn có thể sử dụng lệnh linux này trong thư mục gốc của dự án của bạn để xác định các thư viện có thể chịu trách nhiệm về các vấn đề:

find . -name '*.jar' -exec zipgrep -i onreceivedsslerror {} \; 

này sẽ liệt kê các tập tin bên trong tất cả các file jar của bạn có "OnReceivedSslError" chuỗi.

Sau đó, bạn có thể kiểm tra xem các đề xuất của Google để xử lý lỗ hổng có được tôn trọng trong mỗi tệp được đối sánh hay không.

1

Nếu bạn không cần xử lý mọi thứ trong onReceivedSslErr(WebView,SslErrorHandler,SslError), chỉ cần xóa phương thức này để tránh google play warning.Otherwise , bạn cũng không nên tiếp tục trực tiếp. Dưới đây là một ví dụ bằng cách @sakiM, Webview avoid security alert from google play upon implementation of onReceivedSslError

@Override 
public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { 
    final AlertDialog.Builder builder = new AlertDialog.Builder(this); 
    builder.setMessage(R.string.notification_error_ssl_cert_invalid); 
    builder.setPositiveButton("continue", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 
      handler.proceed(); 
     } 
    }); 
    builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 
      handler.cancel(); 
     } 
    }); 
    final AlertDialog dialog = builder.create(); 
    dialog.show(); 
} 

Nếu phương pháp onReceivedSslErr đã được gọi bởi thư viện thứ 3, chỉ cần liên hệ với nhà cung cấp.

0

Xin chào, đây là giải pháp mới nhất để giải quyết vấn đề của bạn. Hy vọng nó sẽ giúp ai đó:

// COPY PASTE MÃ NÀY VÀ XÓA phương thức onReceivedError().

/** 
      * Notify the host application that an SSL error occurred while loading a 
      * resource. The host application must call either handler.cancel() or 
      * handler.proceed(). Note that the decision may be retained for use in 
      * response to future SSL errors. The default behavior is to cancel the 
      * load. 
      * 
      * @param view The WebView that is initiating the callback. 
      * @param handler An SslErrorHandler object that will handle the user's 
      *    response. 
      * @param error The SSL error object. 
      */ 
      @Override 
      public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { 
       //final AlertDialog.Builder builder = new AlertDialog.Builder(OnlinePayment.this); 
       String msg=""; 
       if(error.getPrimaryError()==SslError.SSL_DATE_INVALID 
         || error.getPrimaryError()== SslError.SSL_EXPIRED 
         || error.getPrimaryError()== SslError.SSL_IDMISMATCH 
         || error.getPrimaryError()== SslError.SSL_INVALID 
         || error.getPrimaryError()== SslError.SSL_NOTYETVALID 
         || error.getPrimaryError()==SslError.SSL_UNTRUSTED) { 
        if(error.getPrimaryError()==SslError.SSL_DATE_INVALID){ 
         msg="The date of the certificate is invalid"; 
        }else if(error.getPrimaryError()==SslError.SSL_INVALID){ 
         msg="A generic error occurred"; 
        } 
        else if(error.getPrimaryError()== SslError.SSL_EXPIRED){ 
         msg="The certificate has expired"; 
        }else if(error.getPrimaryError()== SslError.SSL_IDMISMATCH){ 
         msg="Hostname mismatch"; 
        } 
        else if(error.getPrimaryError()== SslError.SSL_NOTYETVALID){ 
         msg="The certificate is not yet valid"; 
        } 
        else if(error.getPrimaryError()==SslError.SSL_UNTRUSTED){ 
         msg="The certificate authority is not trusted"; 
        } 
       } 
       final AlertDialog.Builder builder = new AlertDialog.Builder(OnlinePayment.this); 
       builder.setMessage(msg); 
       builder.setPositiveButton("continue", new DialogInterface.OnClickListener() { 
        @Override 
        public void onClick(DialogInterface dialog, int which) { 
         handler.proceed(); 
        } 
       }); 
       builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() { 
        @Override 
        public void onClick(DialogInterface dialog, int which) { 
         handler.cancel(); 
        } 
       }); 
       final AlertDialog dialog = builder.create(); 
       dialog.show(); 

      } 
Các vấn đề liên quan