Skip to content

Commit

Permalink
fix could not import PEM certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny-chung committed Nov 15, 2024
1 parent 6fb6a03 commit 6066881
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ fun ClientCertificateKeyPair.Companion.importFrom(bundleFile: File, keyStorePass
}

fun parseCaCertificates(bytes: ByteArray) : List<X509Certificate> {
val certBytes = bytes.tryToConvertPemToDer(startLine = "-----BEGIN PKCS7-----", endLine = "-----END PKCS7-----")
val certBytes = bytes
.tryToConvertPemToDer(startLine = "-----BEGIN CERTIFICATE-----", endLine = "-----END CERTIFICATE-----")
.tryToConvertPemToDer(startLine = "-----BEGIN PKCS7-----", endLine = "-----END PKCS7-----")
return CertificateFactory.getInstance("X.509")
.generateCertificates(ByteArrayInputStream(certBytes)).map { it as X509Certificate }
}
Expand Down

0 comments on commit 6066881

Please sign in to comment.