Commit 578bf673 authored by Janne Koschinski's avatar Janne Koschinski

Fixes crash cluster b1150e0b

parent f627d6f7
Pipeline #524 passed with stages
in 25 minutes and 53 seconds
......@@ -52,6 +52,7 @@ import org.threeten.bp.ZoneId
import org.threeten.bp.format.DateTimeFormatter
import org.threeten.bp.format.FormatStyle
import javax.inject.Inject
import javax.net.ssl.SSLPeerUnverifiedException
class CoreInfoFragment : ServiceBoundFragment() {
......@@ -163,7 +164,12 @@ class CoreInfoFragment : ServiceBoundFragment() {
}
modelHelper.sslSession.toLiveData().observe(this, Observer {
val certificateChain = it?.orNull()?.peerCertificateChain?.map(X509Helper::convert).orEmpty()
val peerCertificateChain = try {
it?.orNull()?.peerCertificateChain
} catch (ignored: SSLPeerUnverifiedException) {
null
}
val certificateChain = peerCertificateChain?.mapNotNull(X509Helper::convert).orEmpty()
val leafCertificate = certificateChain.firstOrNull()
if (leafCertificate != null) {
secureCertificate.text = requireContext().getString(
......
......@@ -39,7 +39,7 @@ import de.kuschku.quasseldroid.viewmodel.QuasselViewModel
import de.kuschku.quasseldroid.viewmodel.data.*
import io.reactivex.Observable
import javax.inject.Inject
import javax.net.ssl.SSLSession
import javax.net.ssl.SSLPeerUnverifiedException
open class QuasselViewModelHelper @Inject constructor(
val quassel: QuasselViewModel
......@@ -80,8 +80,12 @@ open class QuasselViewModelHelper @Inject constructor(
}
val sslSession = connectedSession.flatMapSwitchMap(ISession::sslSession)
val peerCertificateChain = sslSession.mapMap(SSLSession::getPeerCertificateChain).mapMap {
it.mapNotNull(X509Helper::convert)
val peerCertificateChain = sslSession.mapMapNullable {
try {
it.peerCertificateChain.mapNotNull(X509Helper::convert)
} catch (ignored: SSLPeerUnverifiedException) {
null
}
}.mapOrElse(emptyList())
val leafCertificate = peerCertificateChain.map { Optional.ofNullable(it.firstOrNull()) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment