1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Don't crash when trying to connect to an non-SSL service using SSL

Fixes issue 3798
This commit is contained in:
cketti 2011-10-28 04:59:08 +02:00
parent 6c7639023d
commit e3f6561008
2 changed files with 13 additions and 3 deletions

View File

@ -153,9 +153,17 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
afe.getMessage() == null ? "" : afe.getMessage()); afe.getMessage() == null ? "" : afe.getMessage());
} catch (final CertificateValidationException cve) { } catch (final CertificateValidationException cve) {
Log.e(K9.LOG_TAG, "Error while testing settings", cve); Log.e(K9.LOG_TAG, "Error while testing settings", cve);
acceptKeyDialog(
R.string.account_setup_failed_dlg_certificate_message_fmt, // Avoid NullPointerException in acceptKeyDialog()
cve); if (TrustManagerFactory.getLastCertChain() != null) {
acceptKeyDialog(
R.string.account_setup_failed_dlg_certificate_message_fmt,
cve);
} else {
showErrorDialog(
R.string.account_setup_failed_dlg_server_message_fmt,
(cve.getMessage() == null ? "" : cve.getMessage()));
}
} catch (final Throwable t) { } catch (final Throwable t) {
Log.e(K9.LOG_TAG, "Error while testing settings", t); Log.e(K9.LOG_TAG, "Error while testing settings", t);
showErrorDialog( showErrorDialog(

View File

@ -76,6 +76,8 @@ public final class TrustManagerFactory {
public void checkServerTrusted(X509Certificate[] chain, String authType) public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException { throws CertificateException {
// FIXME: Using a static field to store the certificate chain is a bad idea. Instead
// create a CertificateException subclass and store the chain there.
TrustManagerFactory.setLastCertChain(chain); TrustManagerFactory.setLastCertChain(chain);
try { try {
defaultTrustManager.checkServerTrusted(chain, authType); defaultTrustManager.checkServerTrusted(chain, authType);