Skip to content

Commit

Permalink
Catch AssertionError when loading certificates/private key (mTLS) (#4456
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jpelgrom authored Jun 14, 2024
1 parent d516018 commit 4e9c958
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,24 @@ class KeyChainRepositoryImpl @Inject constructor(
if (chain == null) {
chain = try {
KeyChain.getCertificateChain(context, alias!!)
} catch (e: Exception) {
Log.e(TAG, "Exception getting certificate chain", e)
} catch (t: Throwable) {
when (t) {
is AssertionError,
is Exception -> Log.e(TAG, "Issue getting certificate chain", t)
else -> throw t
}
null
}
}
if (key == null) {
key = try {
KeyChain.getPrivateKey(context, alias!!)
} catch (e: Exception) {
Log.e(TAG, "Exception getting private key", e)
} catch (t: Throwable) {
when (t) {
is AssertionError,
is Exception -> Log.e(TAG, "Issue getting private key", t)
else -> throw t
}
null
}
}
Expand Down

0 comments on commit 4e9c958

Please sign in to comment.