package com.owncloud.android.authentication;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.lang.ref.WeakReference;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
}
@Override
- public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
+ public void onReceivedSslError (final WebView view, final SslErrorHandler handler, SslError error) {
Log_OC.d(TAG, "onReceivedSslError : " + error);
// Test 1
X509Certificate x509Certificate = getX509CertificateFromError(error);
try {
isKnowServer = NetworkUtils.isCertInKnownServersStore((Certificate) x509Certificate, mContext);
- } catch (KeyStoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (NoSuchAlgorithmException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CertificateException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (Exception e) {
+ Log_OC.e(TAG, "Exception: " + e.getMessage());
}
}
+
if (isKnowServer) {
handler.proceed();
} else {
-
+ // Show a dialog with the certificate info
+ ((AuthenticatorActivity)mContext).showUntrustedCertDialog(x509Certificate, error);
+// SslUntrustedCertDialog dialog = SslUntrustedCertDialog.newInstance(mContext, x509Certificate, error);
+// FragmentManager fm = ((FragmentActivity)mContext).getSupportFragmentManager();
+// FragmentTransaction ft = fm.beginTransaction();
+// dialog.show(ft, DIALOG_UNTRUSTED_CERT);
+ handler.cancel();
}
}
} catch (CertificateException e) {
x509Certificate = null;
}
- }
-
-// if (x509Certificate != null) {
-// Log_OC.d(TAG, "------>>>>> x509Certificate " + x509Certificate.toString());
-// }
-
+ }
return x509Certificate;
}