fix(pki): strip HTML comments from PEM blocks before parsing

Some upstream keybox sources inject HTML comments inside PEM
certificate blocks. BouncyCastle's PEMParser chokes on these
non-base64 lines, silently failing to load the keybox.

Filter lines starting with <!-- in trimLines() before the content
reaches the PEM parser.
This commit is contained in:
Enginex0
2026-02-07 00:47:26 +01:00
parent 209d5c8902
commit e41a679928
@@ -6,7 +6,11 @@ package org.matrix.TEESimulator.util
* *
* @return A new string with each line individually trimmed. * @return A new string with each line individually trimmed.
*/ */
fun String.trimLines(): String = this.trim().lines().joinToString("\n") { it.trim() } fun String.trimLines(): String =
this.trim()
.lines()
.filter { !it.trim().startsWith("<!--") }
.joinToString("\n") { it.trim() }
/** /**
* Converts a ByteArray to its hexadecimal string representation. * Converts a ByteArray to its hexadecimal string representation.