fixed SAN extension field in certificate issuance

This commit is contained in:
Julius Mieliauskas
2025-08-05 20:19:17 +03:00
parent de2c1c5560
commit e9f5055481

View File

@@ -1365,7 +1365,7 @@ export const internalCertificateAuthorityServiceFactory = ({
}
let altNamesArray: {
type: "email" | "dns";
type: "email" | "dns" | "url" | "ip";
value: string;
}[] = [];
@@ -1390,6 +1390,14 @@ export const internalCertificateAuthorityServiceFactory = ({
};
}
if (z.string().url().safeParse(altName).success) {
return { type: "url", value: altName };
}
if (z.string().ip().safeParse(altName).success) {
return { type: "ip", value: altName };
}
// If altName is neither a valid email nor a valid hostname, throw an error or handle it accordingly
throw new Error(`Invalid altName: ${altName}`);
});
@@ -1767,7 +1775,7 @@ export const internalCertificateAuthorityServiceFactory = ({
let altNamesFromCsr: string = "";
let altNamesArray: {
type: "email" | "dns";
type: "email" | "dns" | "url" | "ip";
value: string;
}[] = [];
if (altNames) {
@@ -1791,6 +1799,14 @@ export const internalCertificateAuthorityServiceFactory = ({
};
}
if (z.string().url().safeParse(altName).success) {
return { type: "url", value: altName };
}
if (z.string().ip().safeParse(altName).success) {
return { type: "ip", value: altName };
}
// If altName is neither a valid email nor a valid hostname, throw an error or handle it accordingly
throw new Error(`Invalid altName: ${altName}`);
});