mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-30 13:12:25 -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
|
* Indicates an error in retrieving the certificate for the alias
|
||||||
* (likely because the alias is invalid or the certificate was deleted)
|
* (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;
|
mAlias = alias;
|
||||||
|
|
||||||
Context context = K9.app;
|
|
||||||
try {
|
try {
|
||||||
mChain = fetchCertificateChain(context, alias);
|
mChain = fetchCertificateChain(context, alias);
|
||||||
mPrivateKey = fetchPrivateKey(context, alias);
|
mPrivateKey = fetchPrivateKey(context, alias);
|
||||||
} catch (KeyChainException e) {
|
} catch (KeyChainException e) {
|
||||||
// The certificate was possibly deleted. Notify user of error.
|
// The certificate was possibly deleted. Notify user of error.
|
||||||
throw new CertificateValidationException(K9.app.getString(
|
final String message = context.getString(
|
||||||
R.string.client_certificate_retrieval_failure, alias), e);
|
R.string.client_certificate_retrieval_failure, alias);
|
||||||
|
throw new CertificateValidationException(message, e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new MessagingException(K9.app.getString(
|
final String message = context.getString(
|
||||||
R.string.client_certificate_retrieval_failure, alias), e);
|
R.string.client_certificate_retrieval_failure, alias);
|
||||||
|
throw new MessagingException(message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@ public class SslHelper {
|
|||||||
if (clientCertificateAlias == null || clientCertificateAlias.isEmpty()) {
|
if (clientCertificateAlias == null || clientCertificateAlias.isEmpty()) {
|
||||||
keyManagers = null;
|
keyManagers = null;
|
||||||
} else {
|
} else {
|
||||||
keyManagers = new KeyManager[] { new KeyChainKeyManager(
|
keyManagers = new KeyManager[] { new KeyChainKeyManager(K9.app, clientCertificateAlias) };
|
||||||
clientCertificateAlias) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||||
|
Loading…
Reference in New Issue
Block a user