From c37accdd40502b9d4096ff9a4bde44619afdfd64 Mon Sep 17 00:00:00 2001
From: Janne Koschinski <janne@kuschku.de>
Date: Thu, 11 Feb 2021 00:57:44 +0100
Subject: [PATCH] Replace deprecated certificate handling

---
 .../main/kotlin/de/kuschku/libquassel/util/TlsInfo.kt |  4 ++--
 .../kotlin/de/kuschku/libquassel/util/X509Helper.kt   | 11 ++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/libquassel/src/main/kotlin/de/kuschku/libquassel/util/TlsInfo.kt b/libquassel/src/main/kotlin/de/kuschku/libquassel/util/TlsInfo.kt
index 3b070eb3b..d2e781dd9 100644
--- a/libquassel/src/main/kotlin/de/kuschku/libquassel/util/TlsInfo.kt
+++ b/libquassel/src/main/kotlin/de/kuschku/libquassel/util/TlsInfo.kt
@@ -19,6 +19,7 @@
 
 package de.kuschku.quasseldroid.util
 
+import java.security.cert.Certificate
 import java.security.cert.X509Certificate
 import javax.net.ssl.SSLSession
 
@@ -63,8 +64,7 @@ data class TlsInfo(
         session.protocol,
         cipherSuite,
         keyExchangeMechanism,
-        session.peerCertificateChain
-          .map(javax.security.cert.X509Certificate::toJavaCertificate)
+        session.peerCertificates.map(Certificate::toX509)
       )
     }
   }
diff --git a/libquassel/src/main/kotlin/de/kuschku/libquassel/util/X509Helper.kt b/libquassel/src/main/kotlin/de/kuschku/libquassel/util/X509Helper.kt
index 0c76f1217..0c5b88177 100644
--- a/libquassel/src/main/kotlin/de/kuschku/libquassel/util/X509Helper.kt
+++ b/libquassel/src/main/kotlin/de/kuschku/libquassel/util/X509Helper.kt
@@ -20,15 +20,12 @@
 package de.kuschku.quasseldroid.util
 
 import java.io.ByteArrayInputStream
+import java.security.cert.Certificate
 import java.security.cert.CertificateFactory
-import java.security.cert.X509Certificate as javaCertificate
-import javax.security.cert.X509Certificate as javaxCertificate
+import java.security.cert.X509Certificate
 
 private val certificateFactory = CertificateFactory.getInstance("X.509")
 
-fun javaxCertificate.toJavaCertificate(): javaCertificate =
+fun Certificate.toX509(): X509Certificate =
   certificateFactory.generateCertificate(ByteArrayInputStream(this.encoded))
-    as javaCertificate
-
-fun javaCertificate.toJavaXCertificate(): javaxCertificate =
-  javaxCertificate.getInstance(this.encoded)
+    as X509Certificate
-- 
GitLab