loadOrCreate

fun loadOrCreate(file: File, alias: String = DEFAULT_ALIAS, password: CharArray = DEFAULT_PASSWORD.toCharArray(), httpsPort: Int = 8443, validityDays: Long = 3650): TlsConfig

Load the keystore at file if it exists, otherwise generate a fresh self-signed cert and persist it there.

Parameters

file

PKCS12 keystore location (e.g. File(context.filesDir, "droid-mcp-tls.p12"))

alias

key entry alias

password

keystore + private-key password (protects the on-disk file; the security boundary is the pinned fingerprint, not this value)

httpsPort

port the TLS server should bind

validityDays

certificate lifetime

Throws

if the keystore exists and the JDK reports password as wrong (on Android, where wrong password and corruption look the same, the keystore is regenerated).

if the keystore exists but holds no entry under alias.