diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt index 73bc3c7d57..615358310f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManager.kt @@ -72,16 +72,7 @@ internal class PinnedTrustManager(private val fingerprints: List, private fun checkTrusted(chain: Array) { val cert = chain[0] - var found = false - - for (allowedFingerprint in fingerprints) { - if (allowedFingerprint.matchesCert(cert)) { - found = true - break - } - } - - if (!found) { + if (!fingerprints.any { it.matchesCert(cert) }) { throw UnrecognizedCertificateException(cert, Fingerprint.newSha256Fingerprint(cert), null) } } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt index 4cdae14f25..98257caefc 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/network/ssl/PinnedTrustManagerApi24.kt @@ -144,15 +144,7 @@ internal class PinnedTrustManagerApi24(private val fingerprints: List) { val cert = chain[0] - var found = false - for (allowedFingerprint in fingerprints) { - if (allowedFingerprint.matchesCert(cert)) { - found = true - break - } - } - - if (!found) { + if (!fingerprints.any { it.matchesCert(cert) }) { throw UnrecognizedCertificateException(cert, Fingerprint.newSha256Fingerprint(cert), null) } }