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

Remove KeyChainKeyManager's dependency on 'K9.app'

This commit is contained in:
cketti 2014-08-18 05:08:01 +02:00
parent 4ce2a56b0c
commit ac08f520ae
2 changed files with 8 additions and 8 deletions

View File

@ -51,20 +51,21 @@ public class KeyChainKeyManager extends X509ExtendedKeyManager {
* Indicates an error in retrieving the certificate for the alias
* (likely because the alias is invalid or the certificate was deleted)
*/
public KeyChainKeyManager(String alias) throws MessagingException {
public KeyChainKeyManager(Context context, String alias) throws MessagingException {
mAlias = alias;
Context context = K9.app;
try {
mChain = fetchCertificateChain(context, alias);
mPrivateKey = fetchPrivateKey(context, alias);
} catch (KeyChainException e) {
// The certificate was possibly deleted. Notify user of error.
throw new CertificateValidationException(K9.app.getString(
R.string.client_certificate_retrieval_failure, alias), e);
final String message = context.getString(
R.string.client_certificate_retrieval_failure, alias);
throw new CertificateValidationException(message, e);
} catch (InterruptedException e) {
throw new MessagingException(K9.app.getString(
R.string.client_certificate_retrieval_failure, alias), e);
final String message = context.getString(
R.string.client_certificate_retrieval_failure, alias);
throw new MessagingException(message, e);
}
}

View File

@ -32,8 +32,7 @@ public class SslHelper {
if (clientCertificateAlias == null || clientCertificateAlias.isEmpty()) {
keyManagers = null;
} else {
keyManagers = new KeyManager[] { new KeyChainKeyManager(
clientCertificateAlias) };
keyManagers = new KeyManager[] { new KeyChainKeyManager(K9.app, clientCertificateAlias) };
}
SSLContext sslContext = SSLContext.getInstance("TLS");