mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 14:38:21 +01:00
Fix SSL certificate out-of-date detection (#2028)
This commit is contained in:
parent
515a3973b7
commit
c5e2b18695
@ -15,16 +15,17 @@ import java.net.ConnectException
|
|||||||
import java.net.SocketException
|
import java.net.SocketException
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
import java.net.UnknownHostException
|
import java.net.UnknownHostException
|
||||||
|
import java.security.cert.CertPathValidatorException
|
||||||
import java.security.cert.CertificateExpiredException
|
import java.security.cert.CertificateExpiredException
|
||||||
import java.security.cert.CertificateNotYetValidException
|
import java.security.cert.CertificateNotYetValidException
|
||||||
import javax.net.ssl.SSLHandshakeException
|
import javax.net.ssl.SSLHandshakeException
|
||||||
|
|
||||||
fun Resources.getErrorString(error: Throwable): String = when (error) {
|
fun Resources.getErrorString(error: Throwable): String = when (error) {
|
||||||
is UnknownHostException -> R.string.error_no_internet
|
is UnknownHostException -> R.string.error_no_internet
|
||||||
|
is ConnectException,
|
||||||
is SocketException,
|
is SocketException,
|
||||||
is SocketTimeoutException,
|
is SocketTimeoutException,
|
||||||
is InterruptedIOException,
|
is InterruptedIOException,
|
||||||
is ConnectException,
|
|
||||||
is StreamResetException -> R.string.error_timeout
|
is StreamResetException -> R.string.error_timeout
|
||||||
is NotLoggedInException -> R.string.error_login_failed
|
is NotLoggedInException -> R.string.error_login_failed
|
||||||
is PasswordChangeRequiredException -> R.string.error_password_change_required
|
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) {
|
fun Throwable.isShouldBeReported(): Boolean = when (this) {
|
||||||
is UnknownHostException,
|
is UnknownHostException,
|
||||||
|
is ConnectException,
|
||||||
is SocketException,
|
is SocketException,
|
||||||
is SocketTimeoutException,
|
is SocketTimeoutException,
|
||||||
is InterruptedIOException,
|
is InterruptedIOException,
|
||||||
is ConnectException,
|
|
||||||
is StreamResetException,
|
is StreamResetException,
|
||||||
is ServiceUnavailableException,
|
is ServiceUnavailableException,
|
||||||
is FeatureDisabledException,
|
is FeatureDisabledException,
|
||||||
@ -70,5 +71,6 @@ private fun Throwable?.isCausedByCertificateNotValidNow(): Boolean {
|
|||||||
private fun Throwable?.isCertificateNotValidNow(): Boolean {
|
private fun Throwable?.isCertificateNotValidNow(): Boolean {
|
||||||
val isNotYetValid = this is CertificateNotYetValidException
|
val isNotYetValid = this is CertificateNotYetValidException
|
||||||
val isExpired = this is CertificateExpiredException
|
val isExpired = this is CertificateExpiredException
|
||||||
return isNotYetValid || isExpired
|
val isInvalidPath = this is CertPathValidatorException
|
||||||
|
return isNotYetValid || isExpired || isInvalidPath
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user