roster-server 2.1.12 → 2.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +39 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -853,8 +853,40 @@ class Roster {
|
|
|
853
853
|
}
|
|
854
854
|
return null;
|
|
855
855
|
};
|
|
856
|
+
const issueAndReloadPemsForServername = async (servername) => {
|
|
857
|
+
const host = normalizeHostInput(servername).trim().toLowerCase();
|
|
858
|
+
if (!host) return null;
|
|
859
|
+
|
|
860
|
+
let pems = resolvePemsForServername(host);
|
|
861
|
+
if (pems) return pems;
|
|
862
|
+
|
|
863
|
+
try {
|
|
864
|
+
await greenlockRuntime.get({ servername: host });
|
|
865
|
+
} catch (error) {
|
|
866
|
+
log.warn(`⚠️ Greenlock issuance failed for ${host}: ${error?.message || error}`);
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
pems = resolvePemsForServername(host);
|
|
870
|
+
if (pems) return pems;
|
|
871
|
+
|
|
872
|
+
// For wildcard zones, try a valid subdomain bootstrap host so Greenlock can
|
|
873
|
+
// resolve the wildcard site without relying on invalid "*.domain" servername input.
|
|
874
|
+
const wildcardSubject = wildcardSubjectForHost(host);
|
|
875
|
+
const zone = wildcardSubject ? wildcardRoot(wildcardSubject) : null;
|
|
876
|
+
if (zone) {
|
|
877
|
+
const bootstrapHost = `bun-bootstrap.${zone}`;
|
|
878
|
+
try {
|
|
879
|
+
await greenlockRuntime.get({ servername: bootstrapHost });
|
|
880
|
+
} catch (error) {
|
|
881
|
+
log.warn(`⚠️ Greenlock wildcard bootstrap failed for ${bootstrapHost}: ${error?.message || error}`);
|
|
882
|
+
}
|
|
883
|
+
pems = resolvePemsForServername(host);
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
return pems;
|
|
887
|
+
};
|
|
856
888
|
const ensureBunDefaultPems = async (primaryDomain) => {
|
|
857
|
-
let pems =
|
|
889
|
+
let pems = await issueAndReloadPemsForServername(primaryDomain);
|
|
858
890
|
if (pems) return pems;
|
|
859
891
|
|
|
860
892
|
const certSubject = primaryDomain.startsWith('*.') ? wildcardRoot(primaryDomain) : primaryDomain;
|
|
@@ -891,12 +923,12 @@ class Roster {
|
|
|
891
923
|
key: defaultPems.key,
|
|
892
924
|
cert: defaultPems.cert,
|
|
893
925
|
SNICallback: (servername, callback) => {
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
926
|
+
issueAndReloadPemsForServername(servername)
|
|
927
|
+
.then((pems) => {
|
|
928
|
+
const selected = pems || defaultPems;
|
|
929
|
+
callback(null, tls.createSecureContext({ key: selected.key, cert: selected.cert }));
|
|
930
|
+
})
|
|
931
|
+
.catch(callback);
|
|
900
932
|
}
|
|
901
933
|
}, dispatcher);
|
|
902
934
|
log.warn(`⚠️ Bun runtime detected: using file-based TLS with SNI for ${primaryDomain} on port ${portNum}`);
|