diff options
author | Ricki Hirner <hirner@bitfire.at> | 2020-09-09 13:50:22 +0300 |
---|---|---|
committer | Ricki Hirner <hirner@bitfire.at> | 2020-09-09 13:50:49 +0300 |
commit | 3b3c2070f39c4e7372c6f763a6aa402522e3ad93 (patch) | |
tree | 6e5dd78684e867673f52c5be5beb3e2de44360d6 | |
parent | 767d1f9759dc1e385b371e426bcf3ecbddfd7424 (diff) |
Show alternative names in UI when they are available (thanks @tasn); show number of loaded trusted certificates in logs
-rw-r--r-- | src/main/java/at/bitfire/cert4android/CustomCertService.kt | 7 | ||||
-rw-r--r-- | src/main/java/at/bitfire/cert4android/TrustCertificateActivity.kt | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/main/java/at/bitfire/cert4android/CustomCertService.kt b/src/main/java/at/bitfire/cert4android/CustomCertService.kt index 4c5e44b..1591f53 100644 --- a/src/main/java/at/bitfire/cert4android/CustomCertService.kt +++ b/src/main/java/at/bitfire/cert4android/CustomCertService.kt @@ -86,9 +86,12 @@ class CustomCertService: Service() { // initialize trustedKeyStore keyStoreFile = File(getDir(KEYSTORE_DIR, Context.MODE_PRIVATE), KEYSTORE_NAME) try { - FileInputStream(keyStoreFile).use { trustedKeyStore.load(it, null) } + FileInputStream(keyStoreFile).use { + trustedKeyStore.load(it, null) + Constants.log.fine("Loaded ${trustedKeyStore.size()} trusted certificate(s)") + } } catch(e: Exception) { - Constants.log.log(Level.INFO, "No persistent key store (yet), creating in-memory key store. This is not an error!", e) + Constants.log.log(Level.INFO, "No key store for trusted certifcates (yet); creating in-memory key store.") try { trustedKeyStore.load(null, null) } catch(e: Exception) { diff --git a/src/main/java/at/bitfire/cert4android/TrustCertificateActivity.kt b/src/main/java/at/bitfire/cert4android/TrustCertificateActivity.kt index 44d16b3..8285c1d 100644 --- a/src/main/java/at/bitfire/cert4android/TrustCertificateActivity.kt +++ b/src/main/java/at/bitfire/cert4android/TrustCertificateActivity.kt @@ -97,16 +97,15 @@ class TrustCertificateActivity: AppCompatActivity() { val cert = certFactory.generateCertificate(ByteArrayInputStream(raw)) as? X509Certificate ?: return@thread try { - val subject = if (cert.issuerAlternativeNames != null) { + val subject = cert.subjectAlternativeNames?.let { altNames -> val sb = StringBuilder() - for (altName in cert.subjectAlternativeNames.orEmpty()) { + for (altName in altNames) { val name = altName[1] if (name is String) sb.append("[").append(altName[0]).append("]").append(name).append(" ") } sb.toString() - } else - cert.subjectDN.name + } ?: /* use CN if alternative names are not available */ cert.subjectDN.name issuedFor.postValue(subject) issuedBy.postValue(cert.issuerDN.toString()) |