Skip to content

Commit

Permalink
fix no error were displayed if importing an invalid certificate was r…
Browse files Browse the repository at this point in the history
…ejected
  • Loading branch information
sunny-chung committed Dec 17, 2023
1 parent 882e585 commit 3f610bf
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,13 @@ fun CertificateEditorView(
*/
fun parseAndAddCertificate(path: String) {
val file = File(path)
val content = file.readBytes()
val cert: X509Certificate = CertificateFactory.getInstance("X.509").generateCertificate(content.inputStream()) as X509Certificate
val (content, cert: X509Certificate) = try {
val content = file.readBytes()
Pair(content, CertificateFactory.getInstance("X.509").generateCertificate(content.inputStream()) as X509Certificate)
} catch (e: Throwable) {
AppContext.ErrorMessagePromptViewModel.showErrorMessage("Error while reading the certificate -- ${e.message ?: e::class.simpleName}")
return
}
log.d { "Loaded cert ${cert}" }

onAddCertificate(
Expand Down

0 comments on commit 3f610bf

Please sign in to comment.