roster-server 2.1.1 → 2.1.2

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.
Files changed (2) hide show
  1. package/index.js +16 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -754,8 +754,18 @@ class Roster {
754
754
  const dispatcher = createDispatcher(portData);
755
755
  const upgradeHandler = createUpgradeHandler(portData);
756
756
  const greenlockStorePath = this.greenlockStorePath;
757
+ const normalizeHostInput = (value) => {
758
+ if (typeof value === 'string') return value;
759
+ if (!value || typeof value !== 'object') return '';
760
+ if (typeof value.servername === 'string') return value.servername;
761
+ if (typeof value.hostname === 'string') return value.hostname;
762
+ if (typeof value.subject === 'string') return value.subject;
763
+ return '';
764
+ };
757
765
  const loadCert = (subjectDir) => {
758
- const certPath = path.join(greenlockStorePath, 'live', subjectDir);
766
+ const normalizedSubject = normalizeHostInput(subjectDir).trim().toLowerCase();
767
+ if (!normalizedSubject) return null;
768
+ const certPath = path.join(greenlockStorePath, 'live', normalizedSubject);
759
769
  const keyPath = path.join(certPath, 'privkey.pem');
760
770
  const certFilePath = path.join(certPath, 'cert.pem');
761
771
  const chainPath = path.join(certPath, 'chain.pem');
@@ -768,13 +778,15 @@ class Roster {
768
778
  return null;
769
779
  };
770
780
  const zoneSubjectForHost = (servername) => {
771
- const labels = String(servername || '').split('.').filter(Boolean);
781
+ const host = normalizeHostInput(servername).trim().toLowerCase();
782
+ const labels = host.split('.').filter(Boolean);
772
783
  if (labels.length < 3) return null;
773
784
  return labels.slice(1).join('.');
774
785
  };
775
786
  const resolvePemsForServername = (servername) => {
776
- if (!servername) return null;
777
- return loadCert(servername) || loadCert(zoneSubjectForHost(servername));
787
+ const host = normalizeHostInput(servername).trim().toLowerCase();
788
+ if (!host) return null;
789
+ return loadCert(host) || loadCert(zoneSubjectForHost(host));
778
790
  };
779
791
 
780
792
  if (portNum === this.defaultPort) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roster-server",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "👾 RosterServer - A domain host router to host multiple HTTPS.",
5
5
  "main": "index.js",
6
6
  "scripts": {