Skip to content

Commit 6df4ea4

Browse files
committed
Cert creation fixes
1 parent cc9d556 commit 6df4ea4

File tree

3 files changed

+30
-13
lines changed

3 files changed

+30
-13
lines changed

frontend/src/modals/CertificateCreateModal/Common/DomainNamesField.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ interface SelectOption extends OptionBase {
1414
}
1515
interface DomainNamesFieldProps {
1616
maxDomains?: number;
17-
isWildcardSupported?: boolean;
17+
isWildcardPermitted?: boolean;
18+
dnsProviderWildcardSupported?: boolean;
1819
onChange?: (i: string[]) => any;
1920
}
2021
function DomainNamesField({
2122
maxDomains,
22-
isWildcardSupported,
23+
isWildcardPermitted,
24+
dnsProviderWildcardSupported,
2325
onChange,
2426
}: DomainNamesFieldProps) {
2527
const { values, setFieldValue } = useFormikContext();
@@ -45,7 +47,10 @@ function DomainNamesField({
4547
}
4648

4749
// Prevent wildcards
48-
if (!isWildcardSupported && dom.indexOf("*") !== -1) {
50+
if (
51+
(!isWildcardPermitted || !dnsProviderWildcardSupported) &&
52+
dom.indexOf("*") !== -1
53+
) {
4954
return false;
5055
}
5156

@@ -71,6 +76,18 @@ function DomainNamesField({
7176
setFieldValue("domainNames", doms);
7277
};
7378

79+
let helperTexts: string[] = [];
80+
if (maxDomains) {
81+
helperTexts.push(
82+
intl.formatMessage({ id: "domain_names.max" }, { count: maxDomains }),
83+
);
84+
}
85+
if (!isWildcardPermitted) {
86+
helperTexts.push(intl.formatMessage({ id: "wildcards-not-permitted" }));
87+
} else if (!dnsProviderWildcardSupported) {
88+
helperTexts.push(intl.formatMessage({ id: "wildcards-not-supported" }));
89+
}
90+
7491
return (
7592
<Field name="domainNames">
7693
{({ field, form }: any) => (
@@ -91,14 +108,11 @@ function DomainNamesField({
91108
isMulti
92109
placeholder="example.com"
93110
/>
94-
{maxDomains ? (
95-
<FormHelperText>
96-
{intl.formatMessage(
97-
{ id: "domain_names.max" },
98-
{ count: maxDomains },
99-
)}
100-
</FormHelperText>
101-
) : null}
111+
{helperTexts.length
112+
? helperTexts.map((i) => {
113+
return <FormHelperText>{i}</FormHelperText>;
114+
})
115+
: null}
102116
<FormErrorMessage>{form.errors.domainNames}</FormErrorMessage>
103117
</FormControl>
104118
)}

frontend/src/modals/CertificateCreateModal/DNSForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function DNSForm() {
2323
<CertificateAuthorityField onChange={handleCAChange} />
2424
<DomainNamesField
2525
maxDomains={maxDomains}
26-
isWildcardSupported={isWildcardSupported}
26+
dnsProviderWildcardSupported={isWildcardSupported}
27+
isWildcardPermitted /* true for DNS certs */
2728
/>
2829
<DNSProviderField />
2930
<EccField />

frontend/src/modals/CertificateCreateModal/HTTPForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ function HTTPForm() {
2222
<CertificateAuthorityField onChange={handleCAChange} />
2323
<DomainNamesField
2424
maxDomains={maxDomains}
25-
isWildcardSupported={isWildcardSupported}
25+
dnsProviderWildcardSupported={
26+
isWildcardSupported
27+
} /* technically not applicable for HTTP certs */
2628
/>
2729
<EccField />
2830
</>

0 commit comments

Comments
 (0)