fix esim trust bundles
- Commit
eb33a448e5ad6e06b03a1f34dfed5d70ffca02f6- Author
- vayun-mathur <[email protected]>
- When
- 2026-09-26 22:33 UTC (2 months ago)
- Parents
1420725
Diff
library/network/src/main/assets/ca/gsma-rsp2-root-ci1.der
diff --git a/library/network/src/main/assets/ca/gsma-rsp2-root-ci1.der b/library/network/src/main/assets/ca/gsma-rsp2-root-ci1.dernew file mode 100644index 0000000000..416a87ecc9Binary files /dev/null and b/library/network/src/main/assets/ca/gsma-rsp2-root-ci1.der differ
library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt b/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.ktindex 3f30104c4c..ae203a2b1e 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/BundledTrust.kt@@ -41,6 +41,20 @@ object BundledTrust { val ks = KeyStore.getInstance(KeyStore.getDefaultType()).apply { load(null, null) } var loaded = 0+ if (bundle.includeSystemIssuers()) {+ // Seed from the platform store so every public-CA host keeps+ // validating; the bundled assets below only ADD ecosystem roots.+ val systemTmf = TrustManagerFactory.getInstance(+ TrustManagerFactory.getDefaultAlgorithm(),+ ).apply { init(null as KeyStore?) }+ val systemIssuers = systemTmf.trustManagers+ .filterIsInstance<X509TrustManager>()+ .flatMap { it.acceptedIssuers.toList() }+ for ((idx, cert) in systemIssuers.withIndex()) {+ ks.setCertificateEntry("system-$idx", cert)+ loaded+++ }+ } for ((idx, path) in assetPaths.withIndex()) { try { context.assets.open(path).use { ins ->
library/network/src/main/java/com/vayunmathur/library/network/TrustBundle.kt
diff --git a/library/network/src/main/java/com/vayunmathur/library/network/TrustBundle.kt b/library/network/src/main/java/com/vayunmathur/library/network/TrustBundle.ktindex 1c55f8b0ef..bcad710919 100644--- a/library/network/src/main/java/com/vayunmathur/library/network/TrustBundle.kt+++ b/library/network/src/main/java/com/vayunmathur/library/network/TrustBundle.kt@@ -21,6 +21,16 @@ package com.vayunmathur.library.network * as its own bundle rather than folded into STANDARD so the other STANDARD apps do not * silently gain a root only musicbrainz needs. * - SYSTEM: platform default; email/web/vpn dynamic hosts.+ * - ESIM: system roots PLUS the GSMA RSP2 CI root. SM-DP+ servers authenticate+ * their TLS layer with certificates issued under the GSMA CI PKI (a closed+ * eSIM-ecosystem PKI, e.g. Thales-hosted carrier endpoints chaining to+ * "GSM Association - RSP2 Root CI1"), which no platform store carries — so+ * system trust alone fails them with CertPathValidatorException while a+ * blanket trust-all would drop the only transport check. Seeding from the+ * platform issuers keeps every public-CA SM-DP+ working; the single extra+ * root only admits the eSIM ecosystem PKI. The eUICC itself still performs+ * the real mutual authentication (AuthenticateServer against its CI PKI), so+ * this bundle never vouches for a server the eUICC would reject. */ enum class TrustBundle { FIRST_PARTY,@@ -28,9 +38,13 @@ enum class TrustBundle { EXTENDED, MUSICBRAINZ, SYSTEM,+ ESIM, ; fun assetPaths(): List<String> = when (this) {+ ESIM -> listOf(+ "ca/gsma-rsp2-root-ci1.der",+ ) FIRST_PARTY -> listOf( "ca/isrgrootx1.der", "ca/isrgrootx2.der",@@ -68,4 +82,12 @@ enum class TrustBundle { ) SYSTEM -> emptyList() }++ /**+ * Whether the bundle starts from the platform's own accepted issuers before+ * adding [assetPaths]. Only ESIM does this: its hosts span arbitrary public+ * CAs plus the GSMA CI root, and enumerating every public root they might+ * use would just be a worse-maintained copy of the system store.+ */+ fun includeSystemIssuers(): Boolean = this == ESIM }
library/src/main/java/com/vayunmathur/library/intents/euicc/EsimLink.kt
diff --git a/library/src/main/java/com/vayunmathur/library/intents/euicc/EsimLink.kt b/library/src/main/java/com/vayunmathur/library/intents/euicc/EsimLink.ktnew file mode 100644index 0000000000..55ff905597--- /dev/null+++ b/library/src/main/java/com/vayunmathur/library/intents/euicc/EsimLink.kt@@ -0,0 +1,35 @@+package com.vayunmathur.library.intents.euicc++/**+ * The standard eSIM universal link both ends of the provisioning handoff share:+ * `https://esimsetup.android.com/esim_qrcode_provisioning?carddata=<activation-code>`.+ *+ * Scanners build this link from the QR payload and fire `ACTION_VIEW`; the LPA+ * whose manifest declares the host+path receives it instead of a browser. This+ * is the same URL the platform's own eSIM flow uses — no app-specific actions+ * or extras.+ */+object EsimLink {+ const val SCHEME = "https"+ const val HOST = "esimsetup.android.com"+ const val PATH = "/esim_qrcode_provisioning"+ const val CARDDATA_PARAM = "carddata"++ /**+ * Package of our euicc app. Scanners pin the VIEW intent here with+ * `setPackage` so it reaches the LPA directly: an unpinned link would+ * otherwise resolve to the browser (which cannot provision anything), and+ * verified App Links are unobtainable for a domain we don't own. Must match+ * the euicc module's `applicationId`.+ */+ const val LPA_PACKAGE = "com.vayunmathur.euicc"++ /** Builds the provisioning link for a scanned activation code. */+ fun provisioningUri(activationCode: String): android.net.Uri =+ android.net.Uri.Builder()+ .scheme(SCHEME)+ .authority(HOST)+ .path(PATH)+ .appendQueryParameter(CARDDATA_PARAM, activationCode)+ .build()+}