improve certificate parsing logic
This commit is contained in:
parent
2b027321a7
commit
fa8bcd543e
@ -63,7 +63,16 @@ class WebIdMetaPluginModule(
|
||||
|
||||
if (input.startsWith("sha256/") || input.startsWith("sha1/")) return input
|
||||
|
||||
val justValue = input.substringAfter("=", input).trim()
|
||||
val justValue =
|
||||
if (input.contains("=")) {
|
||||
val left = input.substringBefore("=").trim()
|
||||
val right = input.substringAfter("=").trim()
|
||||
|
||||
val looksLikeEnvKey = left.isNotEmpty() && left.length <= 64 && left.all { it.isLetterOrDigit() || it == '_' }
|
||||
if (looksLikeEnvKey) right else input
|
||||
} else {
|
||||
input
|
||||
}
|
||||
|
||||
val base64Cert = justValue
|
||||
.replace("-----BEGIN CERTIFICATE-----", "")
|
||||
@ -72,6 +81,8 @@ class WebIdMetaPluginModule(
|
||||
|
||||
require(base64Cert.isNotEmpty()) { "Certificate input is empty after normalization" }
|
||||
|
||||
Log.d("WebIdMetaPlugin", "Base64 certificate: $base64Cert")
|
||||
|
||||
val certBytes = try {
|
||||
Base64.decode(base64Cert, Base64.DEFAULT)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user