@@ -33,6 +33,7 @@ Licensed to the Apache Software Foundation (ASF) under one
33
33
import android .graphics .PorterDuff ;
34
34
import android .graphics .PorterDuffColorFilter ;
35
35
import android .graphics .Color ;
36
+ import android .net .http .SslError ;
36
37
import android .net .Uri ;
37
38
import android .os .Build ;
38
39
import android .os .Bundle ;
@@ -50,6 +51,7 @@ Licensed to the Apache Software Foundation (ASF) under one
50
51
import android .webkit .CookieSyncManager ;
51
52
import android .webkit .HttpAuthHandler ;
52
53
import android .webkit .JavascriptInterface ;
54
+ import android .webkit .SslErrorHandler ;
53
55
import android .webkit .ValueCallback ;
54
56
import android .webkit .WebChromeClient ;
55
57
import android .webkit .WebResourceRequest ;
@@ -1465,6 +1467,46 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
1465
1467
}
1466
1468
}
1467
1469
1470
+ @ Override
1471
+ public void onReceivedSslError (WebView view , SslErrorHandler handler , SslError error ) {
1472
+ super .onReceivedSslError (view , handler , error );
1473
+ try {
1474
+ JSONObject obj = new JSONObject ();
1475
+ obj .put ("type" , LOAD_ERROR_EVENT );
1476
+ obj .put ("url" , error .getUrl ());
1477
+ obj .put ("code" , 0 );
1478
+ obj .put ("sslerror" , error .getPrimaryError ());
1479
+ String message ;
1480
+ switch (error .getPrimaryError ()) {
1481
+ case SslError .SSL_DATE_INVALID :
1482
+ message = "The date of the certificate is invalid" ;
1483
+ break ;
1484
+ case SslError .SSL_EXPIRED :
1485
+ message = "The certificate has expired" ;
1486
+ break ;
1487
+ case SslError .SSL_IDMISMATCH :
1488
+ message = "Hostname mismatch" ;
1489
+ break ;
1490
+ default :
1491
+ case SslError .SSL_INVALID :
1492
+ message = "A generic error occurred" ;
1493
+ break ;
1494
+ case SslError .SSL_NOTYETVALID :
1495
+ message = "The certificate is not yet valid" ;
1496
+ break ;
1497
+ case SslError .SSL_UNTRUSTED :
1498
+ message = "The certificate authority is not trusted" ;
1499
+ break ;
1500
+ }
1501
+ obj .put ("message" , message );
1502
+
1503
+ sendUpdate (obj , true , PluginResult .Status .ERROR );
1504
+ } catch (JSONException ex ) {
1505
+ LOG .d (LOG_TAG , "Should never happen" );
1506
+ }
1507
+ handler .cancel ();
1508
+ }
1509
+
1468
1510
/**
1469
1511
* On received http auth request.
1470
1512
*/
0 commit comments