Merge pull request #5701 from adman234/fix/ssl-toggles-lost-on-new-cert-create

Fix: SSL toggles reset to off when requesting a new certificate on host creation
This commit is contained in:
jc21 authored and GitHub committed 2026-11-18 07:41:48 +10:00
commit 20016b9d91
3 files changed
+54 -6

No files matched your search

+22 -2
View File
@@ -46,7 +46,13 @@ const internalDeadHost = {
// At this point the domains should have been checked
data.owner_user_id = access.token.getUserId(1);
const thisData = internalHost.cleanSslHstsData(data);
// Don't clean the ssl_forced/http2_support/hsts_* fields yet if a
// certificate is about to be requested. certificate_id has already
// been stripped above, so cleanSslHstsData would see "no cert" and
// zero out the SSL toggles the user just submitted, even though a
// certificate is created moments later in this same request.
const thisData = createCertificate ? data : internalHost.cleanSslHstsData(data);
// Fix for db field not having a default value
// for this optional field.
@@ -69,10 +75,24 @@ const internalDeadHost = {
if (createCertificate) {
const cert = await internalCertificate.createQuickCertificate(access, data);
// update host with cert id
// Update host with cert id and re-apply the originally submitted
// SSL toggles, cleaned now that a real certificate exists for them
// to validate against. update() saves the values it is given, so
// they have to be cleaned here (e.g. HSTS off when Force SSL is off).
const sslData = internalHost.cleanSslHstsData({
certificate_id: cert.id,
ssl_forced: thisData.ssl_forced,
http2_support: thisData.http2_support,
hsts_enabled: thisData.hsts_enabled,
hsts_subdomains: thisData.hsts_subdomains,
});
await internalDeadHost.update(access, {
id: row.id,
certificate_id: cert.id,
ssl_forced: sslData.ssl_forced,
http2_support: sslData.http2_support,
hsts_enabled: sslData.hsts_enabled,
hsts_subdomains: sslData.hsts_subdomains,
});
}
+16 -2
View File
@@ -49,7 +49,15 @@ const internalProxyHost = {
.then(() => {
// At this point the domains should have been checked
thisData.owner_user_id = access.token.getUserId(1);
thisData = internalHost.cleanSslHstsData(thisData);
// Don't clean the ssl_forced/http2_support/hsts_* fields yet if a
// certificate is about to be requested. certificate_id has already
// been stripped above, so cleanSslHstsData would see "no cert" and
// zero out the SSL toggles the user just submitted, even though a
// certificate is created moments later in this same request.
if (!createCertificate) {
thisData = internalHost.cleanSslHstsData(thisData);
}
// Fix for db field not having a default value
// for this optional field.
@@ -66,10 +74,16 @@ const internalProxyHost = {
return internalCertificate
.createQuickCertificate(access, thisData)
.then((cert) => {
// update host with cert id
// Update host with cert id and re-apply the originally submitted
// SSL toggles, now that a real certificate exists for them to
// validate against.
return internalProxyHost.update(access, {
id: row.id,
certificate_id: cert.id,
ssl_forced: thisData.ssl_forced,
http2_support: thisData.http2_support,
hsts_enabled: thisData.hsts_enabled,
hsts_subdomains: thisData.hsts_subdomains,
});
})
.then(() => {
+16 -2
View File
@@ -49,7 +49,15 @@ const internalRedirectionHost = {
.then(() => {
// At this point the domains should have been checked
thisData.owner_user_id = access.token.getUserId(1);
thisData = internalHost.cleanSslHstsData(thisData);
// Don't clean the ssl_forced/http2_support/hsts_* fields yet if a
// certificate is about to be requested. certificate_id has already
// been stripped above, so cleanSslHstsData would see "no cert" and
// zero out the SSL toggles the user just submitted, even though a
// certificate is created moments later in this same request.
if (!createCertificate) {
thisData = internalHost.cleanSslHstsData(thisData);
}
// Fix for db field not having a default value
// for this optional field.
@@ -66,10 +74,16 @@ const internalRedirectionHost = {
return internalCertificate
.createQuickCertificate(access, thisData)
.then((cert) => {
// update host with cert id
// Update host with cert id and re-apply the originally submitted
// SSL toggles, now that a real certificate exists for them to
// validate against.
return internalRedirectionHost.update(access, {
id: row.id,
certificate_id: cert.id,
ssl_forced: thisData.ssl_forced,
http2_support: thisData.http2_support,
hsts_enabled: thisData.hsts_enabled,
hsts_subdomains: thisData.hsts_subdomains,
});
})
.then(() => {