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:
parent
4ce2a56b0c
commit
ac08f520ae
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user