Skip to content

Commit

Permalink
Close certificate InputStream after use
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jun 11, 2024
1 parent 9d2d497 commit cdb807c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/src/main/kotlin/com/github/gotify/api/CertUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ internal object CertUtils {
@Throws(GeneralSecurityException::class)
private fun certToTrustManager(certPath: String): Array<TrustManager> {
val certificateFactory = CertificateFactory.getInstance("X.509")
val inputStream = FileInputStream(File(certPath))
val certificates = certificateFactory.generateCertificates(inputStream)
val certificates = FileInputStream(File(certPath)).use(
certificateFactory::generateCertificates
)
require(certificates.isNotEmpty()) { "expected non-empty set of trusted certificates" }

val caKeyStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply { load(null) }
Expand Down

0 comments on commit cdb807c

Please sign in to comment.