Fix SSL certificate out-of-date detection (#2028)

This commit is contained in:
Mikołaj Pich 2022-10-28 11:10:05 +02:00 committed by GitHub
parent 515a3973b7
commit c5e2b18695
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,16 +15,17 @@ import java.net.ConnectException
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import java.security.cert.CertPathValidatorException
import java.security.cert.CertificateExpiredException
import java.security.cert.CertificateNotYetValidException
import javax.net.ssl.SSLHandshakeException
fun Resources.getErrorString(error: Throwable): String = when (error) {
is UnknownHostException -> R.string.error_no_internet
is ConnectException,
is SocketException,
is SocketTimeoutException,
is InterruptedIOException,
is ConnectException,
is StreamResetException -> R.string.error_timeout
is NotLoggedInException -> R.string.error_login_failed
is PasswordChangeRequiredException -> R.string.error_password_change_required
@ -42,10 +43,10 @@ fun Resources.getErrorString(error: Throwable): String = when (error) {
fun Throwable.isShouldBeReported(): Boolean = when (this) {
is UnknownHostException,
is ConnectException,
is SocketException,
is SocketTimeoutException,
is InterruptedIOException,
is ConnectException,
is StreamResetException,
is ServiceUnavailableException,
is FeatureDisabledException,
@ -70,5 +71,6 @@ private fun Throwable?.isCausedByCertificateNotValidNow(): Boolean {
private fun Throwable?.isCertificateNotValidNow(): Boolean {
val isNotYetValid = this is CertificateNotYetValidException
val isExpired = this is CertificateExpiredException
return isNotYetValid || isExpired
val isInvalidPath = this is CertPathValidatorException
return isNotYetValid || isExpired || isInvalidPath
}