Skip to content

Commit 2507e10

Browse files
committed
Add support for wildcard client certs
1 parent 2e4951b commit 2507e10

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/components/settings/connection-settings-card.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { WarningIcon, Icon } from '../../icons';
88
import { trackEvent } from '../../metrics';
99

1010
import { uploadFile } from '../../util/ui';
11-
import { UnreachableCheck, asError, unreachableCheck } from '../../util/error';
11+
import { asError, unreachableCheck } from '../../util/error';
1212

1313
import { UpstreamProxyType, RulesStore } from '../../model/rules/rules-store';
1414
import { ParsedCertificate, ValidationResult } from '../../model/crypto';
@@ -19,7 +19,8 @@ import {
1919
versionSatisfies,
2020
CLIENT_CERT_SERVER_RANGE,
2121
PROXY_CONFIG_RANGE,
22-
CUSTOM_CA_TRUST_RANGE
22+
CUSTOM_CA_TRUST_RANGE,
23+
WILDCARD_CLIENT_CERTS
2324
} from '../../services/service-versions';
2425

2526
import { inputValidation } from '../component-utils';
@@ -69,10 +70,17 @@ const UpstreamProxyDropdown = styled(Select)`
6970
margin-right: 10px;
7071
`;
7172

73+
const isValidClientCertHost = (input: string): boolean =>
74+
isValidHost(input) || input === '*';
75+
7276
const validateHost = inputValidation(isValidHost,
7377
"Should be a plain hostname, optionally with a specific port"
7478
);
7579

80+
const validateClientCertHost = inputValidation(isValidClientCertHost,
81+
"Should be a plain hostname, optionally with a specific port, or '*'"
82+
);
83+
7684
const isValidProxyHost = (host: string | undefined): boolean =>
7785
!!host?.match(/^([^/@]*@)?[A-Za-z0-9\-.]+(:\d+)?$/);
7886
const validateProxyHost = inputValidation(isValidProxyHost,
@@ -426,7 +434,7 @@ class ClientCertificateConfig extends React.Component<{ rulesStore: RulesStore }
426434
value={this.clientCertHostInput}
427435
onChange={action((e: React.ChangeEvent<HTMLInputElement>) => {
428436
this.clientCertHostInput = e.target.value;
429-
validateHost(e.target);
437+
validateClientCertHost(e.target);
430438
})}
431439
/>
432440
{ this.clientCertState === undefined
@@ -477,7 +485,7 @@ class ClientCertificateConfig extends React.Component<{ rulesStore: RulesStore }
477485
}
478486
<SettingsButton
479487
disabled={
480-
!isValidHost(this.clientCertHostInput) ||
488+
!isValidClientCertHost(this.clientCertHostInput) ||
481489
this.clientCertState !== 'decrypted' || // Not decrypted yet, or
482490
!!clientCertificateHostMap[this.clientCertHostInput] // Duplicate host
483491
}
@@ -488,7 +496,11 @@ class ClientCertificateConfig extends React.Component<{ rulesStore: RulesStore }
488496
</ClientCertificatesList>
489497
<SettingsExplanation>
490498
These certificates will be used for client TLS authentication, if requested by the server, when
491-
connecting to their corresponding hostname.
499+
connecting to their corresponding hostname. {
500+
versionSatisfies(serverVersion.value, WILDCARD_CLIENT_CERTS)
501+
? <>Use <code>*</code> to use a certificate for all hosts.</>
502+
: ''
503+
}
492504
</SettingsExplanation>
493505
</>;
494506
}

src/model/send/send-store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export class SendStore {
159159
const hostWithPort = `${url.hostname}:${effectivePort}`;
160160
const clientCertificate = passthroughOptions.clientCertificateHostMap?.[hostWithPort] ||
161161
passthroughOptions.clientCertificateHostMap?.[url.hostname!] ||
162+
passthroughOptions.clientCertificateHostMap?.['*'] ||
162163
undefined;
163164

164165
const additionalCACerts = this.rulesStore.additionalCaCertificates.map((cert) =>

src/services/service-versions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,5 @@ export const TLS_PASSTHROUGH_SUPPORTED = '^1.12.0';
8484
export const CONNECTION_RESET_SUPPORTED = '^1.12.0';
8585
export const SERVER_REST_API_SUPPORTED = '^1.13.0';
8686
export const SERVER_SEND_API_SUPPORTED = '^1.13.0';
87-
export const ADVANCED_PATCH_TRANSFORMS = '^1.18.0';
87+
export const ADVANCED_PATCH_TRANSFORMS = '^1.18.0';
88+
export const WILDCARD_CLIENT_CERTS = '^1.22.0';

0 commit comments

Comments
 (0)