Close certificate InputStream after use
This commit is contained in:
@@ -87,8 +87,9 @@ internal object CertUtils {
|
|||||||
@Throws(GeneralSecurityException::class)
|
@Throws(GeneralSecurityException::class)
|
||||||
private fun certToTrustManager(certPath: String): Array<TrustManager> {
|
private fun certToTrustManager(certPath: String): Array<TrustManager> {
|
||||||
val certificateFactory = CertificateFactory.getInstance("X.509")
|
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||||
val inputStream = FileInputStream(File(certPath))
|
val certificates = FileInputStream(File(certPath)).use(
|
||||||
val certificates = certificateFactory.generateCertificates(inputStream)
|
certificateFactory::generateCertificates
|
||||||
|
)
|
||||||
require(certificates.isNotEmpty()) { "expected non-empty set of trusted certificates" }
|
require(certificates.isNotEmpty()) { "expected non-empty set of trusted certificates" }
|
||||||
|
|
||||||
val caKeyStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply { load(null) }
|
val caKeyStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply { load(null) }
|
||||||
|
|||||||
Reference in New Issue
Block a user