feat(native): a client certificate can be added on the address screen before connecting

The import was only offered once the check saw the proxy ask for a certificate during the handshake. A proxy that refuses without asking left no way in. The wiki also points to the certificate's new place in Settings and explains why a certificate from an iOS configuration profile cannot be used by the app.
This commit is contained in:
Maurice
2026-11-12 08:42:16 +01:00
parent 1323183cce
commit cc5eca5553
4 changed files with 63 additions and 5 deletions
+12
View File
@@ -74,6 +74,18 @@ export function candidateUrls(input: string): string[] {
return candidates.filter((url): url is string => url !== null);
}
/**
* The host and port a client certificate added on the address screen, before
* any check, is kept for: the https address the typed text stands for. Null
* for nothing typed or a plain http address, which never gets a certificate.
*/
export function certificateTargetFor(input: string): { host: string; port: number } | null {
const https = candidateUrls(input).find((url) => url.startsWith('https://'));
if (!https) return null;
const url = new URL(https);
return { host: url.hostname.toLowerCase(), port: url.port ? Number(url.port) : 443 };
}
function isRecord(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null;
}