diff --git a/res/values/strings.xml b/res/values/strings.xml index 3139b079f..f3a841d67 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1129,6 +1129,7 @@ Please submit bug reports, contribute new features and ask questions at Use client certificate No client certificate Remove client certificate selection - "Failed to retrieve client certificate for alias %s" + "Failed to retrieve client certificate for alias \"%s\"" Advanced options + "Client certificate \"%1$s\" has expired or is not yet valid (%2$s)" diff --git a/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java b/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java index 3efbf4c36..c15fc58ad 100644 --- a/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java +++ b/src/com/fsck/k9/net/ssl/KeyChainKeyManager.java @@ -4,6 +4,7 @@ package com.fsck.k9.net.ssl; import java.net.Socket; import java.security.Principal; import java.security.PrivateKey; +import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.List; @@ -76,6 +77,14 @@ public class KeyChainKeyManager extends X509ExtendedKeyManager { if (chain == null || chain.length == 0) { throw new MessagingException("No certificate chain found for: " + alias); } + try { + for (X509Certificate certificate : chain) { + certificate.checkValidity(); + } + } catch (CertificateException e) { + // Client certificate has expired or is not yet valid + throw new CertificateValidationException(context.getString(R.string.client_certificate_expired, alias, e.toString())); + } return chain; }