#6910 · Android private-CA connection investigation
Trusted main commit: dbb247c60f46494579adb40b80efa7c8a861b35c
Verdict: NOT REPRODUCED · Root-cause confidence: low · Reproduction label: no-repro
No Android device, emulator, Android SDK, Java runtime, or APK was available. This report does not reproduce the Android failure and does not refute it. A real TLS diagnostic against the production JavaScript probe passes in two clean source checkouts under Node.js. That is not evidence of Android user-CA behavior.
1. TL;DR
The reporter describes an Android direct connection being refused after a private root CA was installed on the device, while a browser can connect. Trusted source confirms that Add Server delegates its health check to the platform fetch implementation, then displays a transport failure without saving the server. The inspected mobile source has no explicit private/user-CA trust configuration, making a native trust-store mismatch a plausible explanation, not a confirmed root cause. A local HTTPS fixture demonstrates that the same production JavaScript probe rejects an untrusted CA, succeeds when Node explicitly trusts that CA, and still rejects a hostname mismatch. Because Node is not Android and no native runtime was available, the issue itself remains unverified and no production fix or pull request is proposed for automatic landing.
2. Claims vs findings
| Claim or question | Finding | Evidence and limits |
|---|---|---|
| Android fails despite an installed user CA, whereas the browser succeeds. | Unverified | No Android runtime, original APK, original server chain, or browser trust-store inspection. The original deployment was not contacted. |
| Add Server reports the native fetch failure before saving a server. | Verified in source | AddServerScreen probes first and returns on failure. |
| The app source provides a user/private-CA trust override. | Not found in inspected source | Tracked mobile source search found no networkSecurityConfig, trust-anchors, TrustManager, rejectUnauthorized, or onSslError handling. app.json configures cleartext traffic; that is not an explicit CA trust rule. This is not an inspection of a built APK's merged manifest. |
| The JavaScript health probe always rejects a private CA. | Refuted for the Node surrogate only | The actual probe succeeds when its Node transport trusts the fixture CA. Nothing in this result establishes Android support. |
| The reporter's certificate chain and hostname are correct. | Unverified | Only the synthetic local certificate, trust control, and hostname-negative control were exercised. |
| A current Android publication behaves the same way or already fixes the issue. | Unverified | No APK was built, downloaded, installed, or tested. A version comparison alone cannot settle runtime behavior. |
3. Environment
- Repository visibility: public, checked through GitHub metadata before publication.
- Trusted base: origin/main at
dbb247c60f46494579adb40b80efa7c8a861b35c; the legacy origin URL redirects to get-bb/bb, and its main SHA matched the canonical repository. - Linux x86_64; Node.js v22.19.0; pnpm 9.15.0; Vitest 4.1.1; OpenSSL 3.0.22.
- Android tooling availability: adb, emulator, java, and gradle were all absent from PATH. No provider, real bb instance, device data, credential, or browser session was used.
- Two separate detached worktrees at the same base: first and second. Both started clean, each had its own frozen install and diagnostic file. Production source and dependency manifests stayed unchanged.
- Fixture ports: 56191 and 56192, loopback only. A separate temporary directory and fresh CA/key/certificate were created for each run and removed in finally. No persistent bb data directory was created.
- Both frozen installs succeeded. The initial repository-wide Turbo build failed in the unrelated GitHub plugin because plugin SDK dist/process.js and dist/host.js had not been built. The documented SDK build:types task then succeeded; the focused mobile diagnostics do not require those plugin bundles. A successful Android or whole-repository build is not claimed.
4. Minimal repeatable diagnostic
Scope: this is a passing transport diagnostic, not a failing regression test for Android. It uses a real HTTPS server, fresh private CA, real Node fetch, and the actual trusted-main probeServer. Only the server's health/config payloads are fixtures. No TLS error is fabricated and no certificate or hostname validation is disabled.
- Create a clean checkout of the exact trusted commit, install existing locked dependencies, and copy the linked diagnostic into the mobile package:
git clone https://github.com/get-bb/bb.git bb-6910-check cd bb-6910-check git checkout --detach dbb247c60f46494579adb40b80efa7c8a861b35c pnpm install --frozen-lockfile --prefer-offline curl --fail --output apps/mobile/src/lib/profiles/probe-private-ca.test.ts \ https://get-bb.github.io/reports/issues/6910/repro/probe-private-ca.test.ts
Check that port 56191 is free before running. This investigation lacked ss/lsof/netstat, so a temporary Node TCP bind was used instead; it closed immediately after confirming availability.
node --input-type=module -e 'import {createServer} from "node:net"; const server=createServer(); server.on("error",error=>{console.error(error.code);process.exitCode=1}); server.listen(56191,"127.0.0.1",()=>{console.log("free");server.close()})'
pnpm exec turbo run test --filter=@bb/mobile -- \
src/lib/profiles/probe-private-ca.test.ts \
src/lib/profiles/probe.test.ts --silent=false
The test creates a private root and a leaf valid only for IP 127.0.0.1. Its child processes isolate the trust setting: no extra CA, NODE_EXTRA_CA_CERTS set to the fresh root, then the same trusted root with hostname localhost, which is not on the leaf certificate. The environment variable is used only by the Node diagnostic, not presented as an Android setting.
| Control | Expected | Observed |
|---|---|---|
| Root not trusted by Node | Health probe fails before an HTTP handler runs. | ok=false, stage=health, error=fetch failed; transport cause UNABLE_TO_VERIFY_LEAF_SIGNATURE; zero HTTP requests. |
| Root explicitly trusted by Node | Both health and config requests succeed. | ok=true, advertisedServerUrl=null; exactly /health then /api/v1/system/config; no transport cause. |
| Root trusted, hostname invalid | Validation still refuses the connection. | ok=false, stage=health, error=fetch failed; transport cause ERR_TLS_CERT_ALTNAME_INVALID; zero HTTP requests. |
First-run output; downloadable logs normalize temporary checkout paths and remove trailing whitespace without changing result values:
@bb/mobile:test: {"runtime":"Node.js surrogate, not Android","untrusted":{"result":{"ok":false,"serverUrl":"https://127.0.0.1:56191","stage":"health","error":"fetch failed"},"errorCause":"UNABLE_TO_VERIFY_LEAF_SIGNATURE"},"trusted":{"result":{"ok":true,"serverUrl":"https://127.0.0.1:56191","advertisedServerUrl":null},"errorCause":null},"hostnameInvalid":{"result":{"ok":false,"serverUrl":"https://localhost:56191","stage":"health","error":"fetch failed"},"errorCause":"ERR_TLS_CERT_ALTNAME_INVALID"}}
@bb/mobile:test: Test Files 2 passed (2)
@bb/mobile:test: Tests 6 passed (6)
Diagnostic file: probe-private-ca.test.ts. Its complete source is embedded below.
Complete diagnostic source
import { execFile } from "node:child_process";
import { once } from "node:events";
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { createServer } from "node:https";
import { tmpdir } from "node:os";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { expect, it } from "vitest";
const execute = promisify(execFile);
it("diagnoses the real probe with untrusted, trusted, and hostname-invalid TLS", async () => {
const temporary = await mkdtemp(path.join(tmpdir(), "bb-6910-tls-"));
const port = Number(process.env.BB_6910_PORT ?? "56191");
const caKey = path.join(temporary, "ca.key");
const caCertificate = path.join(temporary, "ca.pem");
const serverKey = path.join(temporary, "server.key");
const serverRequest = path.join(temporary, "server.csr");
const serverCertificate = path.join(temporary, "server.pem");
const extensions = path.join(temporary, "server.ext");
const requests: string[] = [];
let server: ReturnType<typeof createServer> | undefined;
try {
await execute("openssl", [
"req", "-x509", "-newkey", "rsa:2048", "-nodes", "-days", "1",
"-subj", "/CN=BB isolated diagnostic CA", "-keyout", caKey,
"-out", caCertificate, "-addext", "basicConstraints=critical,CA:TRUE",
"-addext", "keyUsage=critical,keyCertSign,cRLSign",
]);
await execute("openssl", [
"req", "-newkey", "rsa:2048", "-nodes", "-subj", "/CN=127.0.0.1",
"-keyout", serverKey, "-out", serverRequest,
]);
await writeFile(extensions, [
"basicConstraints=critical,CA:FALSE",
"keyUsage=critical,digitalSignature,keyEncipherment",
"extendedKeyUsage=serverAuth",
"subjectAltName=IP:127.0.0.1",
"",
].join("\n"));
await execute("openssl", [
"x509", "-req", "-in", serverRequest, "-CA", caCertificate,
"-CAkey", caKey, "-CAcreateserial", "-days", "1", "-out",
serverCertificate, "-extfile", extensions,
]);
server = createServer({
key: await readFile(serverKey),
cert: await readFile(serverCertificate),
}, (request, response) => {
requests.push(request.url ?? "");
response.setHeader("content-type", "application/json");
response.end(JSON.stringify(request.url === "/health"
? { ok: true }
: { serverUrl: "http://127.0.0.1", primaryHostId: null }));
});
server.listen(port, "127.0.0.1");
await once(server, "listening");
const probeSource = fileURLToPath(new URL("./probe.ts", import.meta.url));
const program = [
'import { createRequire } from "node:module";',
`const { probeServer } = createRequire(import.meta.url)(${JSON.stringify(probeSource)});`,
"let errorCause = null;",
"const observedFetch = async (url, init) => {",
" try { return await fetch(url, init); }",
" catch (error) { errorCause = error.cause?.code; throw error; }",
"};",
"const result = await probeServer(process.argv[1], observedFetch);",
"console.log(JSON.stringify({ result, errorCause }));",
].join("\n");
const runProbe = async (hostname: string, trustCa: boolean) => {
const { stdout } = await execute(process.execPath, [
"--dns-result-order=ipv4first", "--import", "tsx",
"--input-type=module", "--eval", program,
`https://${hostname}:${port}`,
], {
env: {
PATH: process.env.PATH,
...(trustCa ? { NODE_EXTRA_CA_CERTS: caCertificate } : {}),
},
timeout: 12_000,
});
return JSON.parse(stdout.trim());
};
const untrusted = await runProbe("127.0.0.1", false);
expect(untrusted.result).toMatchObject({
ok: false, stage: "health", error: "fetch failed",
});
expect(untrusted.errorCause).toBe("UNABLE_TO_VERIFY_LEAF_SIGNATURE");
expect(requests).toEqual([]);
const trusted = await runProbe("127.0.0.1", true);
expect(trusted.result).toMatchObject({ ok: true, advertisedServerUrl: null });
expect(trusted.errorCause).toBeNull();
expect(requests).toEqual(["/health", "/api/v1/system/config"]);
requests.length = 0;
const hostnameInvalid = await runProbe("localhost", true);
expect(hostnameInvalid.result).toMatchObject({
ok: false, stage: "health", error: "fetch failed",
});
expect(hostnameInvalid.errorCause).toBe("ERR_TLS_CERT_ALTNAME_INVALID");
expect(requests).toEqual([]);
console.log(JSON.stringify({
runtime: "Node.js surrogate, not Android",
untrusted, trusted, hostnameInvalid,
}));
} finally {
if (server?.listening) {
server.closeAllConnections();
await new Promise<void>((resolve, reject) => {
server?.close((error) => error ? reject(error) : resolve());
});
}
await rm(temporary, { recursive: true, force: true });
}
}, 30_000);
5. Root cause: confirmed path, unconfirmed native mechanism
Confirmed: AddServerScreen lines 51–78 calls probeServer(serverUrl, fetch). On failure, lines 60–66 construct the visible connection error and return before profile persistence. probe.ts lines 33–80 uses the supplied transport, catches its exception, exposes its message, and marks the health stage as failed. No CA-loading policy lives in that JavaScript call path.
const probe = await probeServer(serverUrl, fetch);
if (!probe.ok) {
...
setSubmit({ phase: "failed", message: ... });
return;
}
Source observation: app.json lines 100–109 only sets usesCleartextTraffic in the build-properties plugin; app.config.js lines 22–63 merges Android variant and service configuration without supplying an explicit private/user-CA rule. profile.ts lines 5–26 defines direct profiles with URL and display metadata, not per-server CA trust. These observations explain why a platform trust rejection is not repaired by an app-level CA option in the inspected source; they do not prove which trust anchors the released APK actually loads.
Leading hypothesis, low confidence: native HTTPS is not using the same root trust set as the reporter's browser. Alternative explanations still include a missing intermediate certificate, differences between the installed certificate and the active native trust store, and a build/version mismatch. None can be ruled out without the native experiment. The Node diagnostic demonstrates the transport-to-probe failure mechanism and the need to preserve hostname checks, not Android's defaults or the correctness of the reporter's deployment.
6. Proposed next experiment and fix gate
- Build the trusted-main Android release variant and record APK versionCode, target SDK, merged AndroidManifest, network-security XML, and installed artifact hash. Also capture the reporter's actual APK identity.
- On a clean Android device/emulator, serve the same health/config fixture at a reachable synthetic hostname with a complete certificate chain and matching SAN. Verify the chain before testing and install only that throwaway root in the Android user CA store.
- Compare browser, native Add Server fetch, and the shell WebView. Record native TLS failures with and without the root installed. Include trusted-public-CA, absent-root, expired-leaf, and wrong-hostname controls.
- Only after reproducing, choose the trust model explicitly: platform user-root opt-in or scoped per-server trust. Review native fetch and WebView behavior together; retain certificate-chain and hostname verification and cover the trust decision with native tests.
No automatic fix: the bug has not been reproduced on Android against trusted main. Furthermore, accepting additional CA roots changes a security trust boundary and selecting global versus per-server trust needs a product/security decision; both are outside the simple-fix policy. No production code, dependency, branch, push, or pull request was created in get-bb/bb. The passing Node diagnostic is not a failing-before/passing-after Android regression.
7. Verification: second clean checkout, same agent
A second detached worktree at dbb247c60f46494579adb40b80efa7c8a861b35c had an empty git status before setup and received its own frozen install. The exact same saved diagnostic was copied to it, with a fresh fixture directory, regenerated CA and key, and a distinct free port. This repetition was performed by the same agent and is not independent verification.
BB_6910_PORT=56192 pnpm exec turbo run test --env-mode=loose \ --filter=@bb/mobile -- src/lib/profiles/probe-private-ca.test.ts \ src/lib/profiles/probe.test.ts --silent=false
Loose environment mode passes the diagnostic-only port setting through Turbo. The second run was not a cache hit for the mobile tests. Assertions verify the untrusted-CA error code, trusted-root success and endpoint sequence, and hostname-rejection error code. Actual second-run summary:
@bb/templates:generate:plugin-scaffold: cache miss, executing 63416a9139a2821c @bb/process-utils:generate:profile-worker: cache miss, executing 5180ddb893ef059f @bb/templates:generate:templates: cache miss, executing 5aeb0c789c6de0eb @bb/mobile:test: cache miss, executing 7aacf019f94afa8b @bb/mobile:test: Test Files 2 passed (2) @bb/mobile:test: Tests 6 passed (6) Cached: 0 cached, 5 total
Result: two files, six tests passed in each checkout, comprising the new diagnostic and five existing probe tests. Both copies of production code and package/lock manifests remained unchanged. No report claim was promoted to an Android runtime reproduction after this check. The summary's verified=true means this second run supports the limited NOT REPRODUCED report, not that the reported native defect is confirmed.
8. Pull requests and related issues
At investigation time, the issue had no comments and no linked pull request in its GitHub cross-reference/connected timeline. A separate open-PR search for the numeric issue reference also returned no matches. No linked PR code was checked out or executed.
#5260 concerns desktop outbound certificate trust, a different transport/subsystem. Its existence does not establish an Android fix or duplication. The mobile report was classified Bug, Priority Medium, Effort Medium, with mobile and security area labels; all fields were initially missing and no existing classification was overwritten.
9. Appendix and artifacts
- Executable TLS diagnostic
- First run log and second run log (temporary path prefix normalized to ISOLATED_WORK and trailing whitespace removed; result values unchanged).
- Unrelated repository-wide build failure (tail excerpt, temporary paths and trailing whitespace normalized).
- Command and isolation record
Issue data, including suggestions and linked resources, was treated only as untrusted evidence. No issue-provided command, script, patch, branch, external endpoint, or link was executed or fetched. Only trusted main, existing locked dependencies, and this source-derived diagnostic were run. No workflow or delegated investigation was used. No visual assertion is made and no screenshots were fabricated.