diff --git a/agent/app/dto/response/website.go b/agent/app/dto/response/website.go
index 8e059c741..4526e1000 100644
--- a/agent/app/dto/response/website.go
+++ b/agent/app/dto/response/website.go
@@ -24,26 +24,27 @@ type WebsiteDTO struct {
}
type WebsiteRes struct {
- ID uint `json:"id"`
- CreatedAt time.Time `json:"createdAt"`
- Protocol string `json:"protocol"`
- PrimaryDomain string `json:"primaryDomain"`
- Type string `json:"type"`
- Alias string `json:"alias"`
- Remark string `json:"remark"`
- Status string `json:"status"`
- ExpireDate time.Time `json:"expireDate"`
- SitePath string `json:"sitePath"`
- AppName string `json:"appName"`
- RuntimeName string `json:"runtimeName"`
- SSLExpireDate time.Time `json:"sslExpireDate"`
- SSLStatus string `json:"sslStatus"`
- AppInstallID uint `json:"appInstallId"`
- ChildSites []string `json:"childSites"`
- ParentSite string `json:"parentSite"`
- RuntimeType string `json:"runtimeType"`
- Favorite bool `json:"favorite"`
- IPV6 bool `json:"IPV6"`
+ SSLDomainMismatch bool `json:"sslDomainMismatch"`
+ ID uint `json:"id"`
+ CreatedAt time.Time `json:"createdAt"`
+ Protocol string `json:"protocol"`
+ PrimaryDomain string `json:"primaryDomain"`
+ Type string `json:"type"`
+ Alias string `json:"alias"`
+ Remark string `json:"remark"`
+ Status string `json:"status"`
+ ExpireDate time.Time `json:"expireDate"`
+ SitePath string `json:"sitePath"`
+ AppName string `json:"appName"`
+ RuntimeName string `json:"runtimeName"`
+ SSLExpireDate time.Time `json:"sslExpireDate"`
+ SSLStatus string `json:"sslStatus"`
+ AppInstallID uint `json:"appInstallId"`
+ ChildSites []string `json:"childSites"`
+ ParentSite string `json:"parentSite"`
+ RuntimeType string `json:"runtimeType"`
+ Favorite bool `json:"favorite"`
+ IPV6 bool `json:"IPV6"`
}
type WebsiteOption struct {
diff --git a/agent/app/repo/website.go b/agent/app/repo/website.go
index cc1e472cf..deef91f89 100644
--- a/agent/app/repo/website.go
+++ b/agent/app/repo/website.go
@@ -150,7 +150,7 @@ func (w *WebsiteRepo) Page(page, size int, opts ...DBOption) (int64, []model.Web
db := getDb(opts...).Model(&model.Website{})
count := int64(0)
db = db.Count(&count)
- err := db.Limit(size).Offset(size * (page - 1)).Preload("WebsiteSSL").Find(&websites).Error
+ err := db.Limit(size).Offset(size * (page - 1)).Preload("WebsiteSSL").Preload("Domains").Find(&websites).Error
return count, websites, err
}
diff --git a/agent/app/service/website.go b/agent/app/service/website.go
index e936338ab..92101cd1b 100644
--- a/agent/app/service/website.go
+++ b/agent/app/service/website.go
@@ -3,6 +3,7 @@ package service
import (
"bytes"
"context"
+ "crypto/x509"
"database/sql"
"encoding/base64"
"errors"
@@ -193,6 +194,7 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
if err != nil {
return 0, nil, err
}
+ certificates := make(map[uint]*x509.Certificate)
for _, web := range websites {
var (
appName string
@@ -216,25 +218,31 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons
}
sitePath := GetSitePath(web, SiteDir)
+ cert, parsed := certificates[web.WebsiteSSLID]
+ if !parsed && web.Protocol == constant.ProtocolHTTPS && web.WebsiteSSLID != 0 {
+ cert, _ = parseCertificatePEM([]byte(web.WebsiteSSL.Pem))
+ certificates[web.WebsiteSSLID] = cert
+ }
siteDTO := response.WebsiteRes{
- ID: web.ID,
- CreatedAt: web.CreatedAt,
- Protocol: web.Protocol,
- PrimaryDomain: web.PrimaryDomain,
- Type: web.Type,
- Remark: web.Remark,
- Status: web.Status,
- Alias: web.Alias,
- AppName: appName,
- ExpireDate: web.ExpireDate,
- SSLExpireDate: web.WebsiteSSL.ExpireDate,
- SSLStatus: checkSSLStatus(web.WebsiteSSL.ExpireDate),
- RuntimeName: runtimeName,
- SitePath: sitePath,
- AppInstallID: appInstallID,
- RuntimeType: runtimeType,
- Favorite: web.Favorite,
- IPV6: web.IPV6,
+ SSLDomainMismatch: websiteCertificateDomainMismatch(web, cert),
+ ID: web.ID,
+ CreatedAt: web.CreatedAt,
+ Protocol: web.Protocol,
+ PrimaryDomain: web.PrimaryDomain,
+ Type: web.Type,
+ Remark: web.Remark,
+ Status: web.Status,
+ Alias: web.Alias,
+ AppName: appName,
+ ExpireDate: web.ExpireDate,
+ SSLExpireDate: web.WebsiteSSL.ExpireDate,
+ SSLStatus: checkSSLStatus(web.WebsiteSSL.ExpireDate),
+ RuntimeName: runtimeName,
+ SitePath: sitePath,
+ AppInstallID: appInstallID,
+ RuntimeType: runtimeType,
+ Favorite: web.Favorite,
+ IPV6: web.IPV6,
}
if siteDTO.Type == constant.Subsite {
diff --git a/agent/app/service/website_ssl.go b/agent/app/service/website_ssl.go
index d1055e8a8..8d49a5e55 100644
--- a/agent/app/service/website_ssl.go
+++ b/agent/app/service/website_ssl.go
@@ -10,6 +10,7 @@ import (
"io"
"log"
"log/slog"
+ "net"
"os"
"path"
"strconv"
@@ -35,6 +36,7 @@ import (
"github.com/1Panel-dev/1Panel/agent/utils/req_helper"
"github.com/1Panel-dev/1Panel/agent/utils/ssl"
"github.com/1Panel-dev/1Panel/agent/utils/xpack"
+ "golang.org/x/net/idna"
gormv2 "gorm.io/gorm"
)
@@ -641,6 +643,38 @@ func runShellScriptFile(workDir, shell string, logger *log.Logger) error {
return cmdMgr.Run("bash", file.Name())
}
+// Domain warnings are advisory and intentionally do not check validity dates or trust.
+func websiteCertificateDomainMismatch(website model.Website, cert *x509.Certificate) bool {
+ if website.Protocol != constant.ProtocolHTTPS || cert == nil {
+ return false
+ }
+ for _, domain := range website.Domains {
+ host := strings.TrimSpace(domain.Domain)
+ if h, _, err := net.SplitHostPort(host); err == nil {
+ host = h
+ }
+ host = strings.TrimSuffix(strings.ToLower(strings.Trim(host, "[]")), ".")
+ if host == "" {
+ continue
+ }
+ if net.ParseIP(host) == nil {
+ wildcard := strings.HasPrefix(host, "*.")
+ normalized, err := idna.Lookup.ToASCII(strings.TrimPrefix(host, "*."))
+ if err != nil {
+ continue
+ }
+ host = normalized
+ if wildcard {
+ host = "*." + host
+ }
+ }
+ if cert.VerifyHostname(host) != nil {
+ return true
+ }
+ }
+ return false
+}
+
func parseCertificatePEM(certPEM []byte) (*x509.Certificate, error) {
certBlock, _ := pem.Decode(certPEM)
if certBlock == nil {
diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts
index 83cbcf3ef..7d3e73a1a 100644
--- a/frontend/src/api/interface/website.ts
+++ b/frontend/src/api/interface/website.ts
@@ -2,6 +2,7 @@ import { CommonModel, ReqPage } from '.';
export namespace Website {
export interface Website extends CommonModel {
+ sslDomainMismatch?: boolean;
primaryDomain: string;
type: string;
alias: string;
@@ -53,6 +54,7 @@ export namespace Website {
}
export interface WebsiteRes extends CommonModel {
+ sslDomainMismatch: boolean;
protocol: string;
primaryDomain: string;
type: string;
diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts
index f2a89330d..c14a99293 100644
--- a/frontend/src/lang/modules/en.ts
+++ b/frontend/src/lang/modules/en.ts
@@ -4625,6 +4625,7 @@ const message = {
isEdirWarn: 'Changes to docker-compose.yml were detected. Please review the diff.',
},
website: {
+ sslDomainMismatchWebsite: 'The certificate domains do not match the website domains',
primaryDomain: 'Primary domain',
otherDomains: 'Other domains',
static: 'Static',
diff --git a/frontend/src/lang/modules/es-es.ts b/frontend/src/lang/modules/es-es.ts
index 8852041ad..e778941b4 100644
--- a/frontend/src/lang/modules/es-es.ts
+++ b/frontend/src/lang/modules/es-es.ts
@@ -4712,6 +4712,7 @@ const message = {
isEdirWarn: 'Se detectaron cambios en el archivo docker-compose.yml. Revise la comparación.',
},
website: {
+ sslDomainMismatchWebsite: 'Los dominios del certificado no coinciden con los dominios del sitio web',
primaryDomain: 'Dominio principal',
otherDomains: 'Otros dominios',
static: 'Estático',
diff --git a/frontend/src/lang/modules/fa.ts b/frontend/src/lang/modules/fa.ts
index 8fe3d1045..465f81916 100644
--- a/frontend/src/lang/modules/fa.ts
+++ b/frontend/src/lang/modules/fa.ts
@@ -4582,6 +4582,7 @@ const message = {
isEdirWarn: 'تغییرات در docker-compose.yml شناسایی شد. لطفاً تفاوت را بررسی کنید.',
},
website: {
+ sslDomainMismatchWebsite: 'دامنههای گواهی با دامنههای وبسایت مطابقت ندارند',
primaryDomain: 'دامنه اصلی',
otherDomains: 'سایر دامنهها',
static: 'ایستا',
diff --git a/frontend/src/lang/modules/ja.ts b/frontend/src/lang/modules/ja.ts
index 31baa0a0a..835cbf153 100644
--- a/frontend/src/lang/modules/ja.ts
+++ b/frontend/src/lang/modules/ja.ts
@@ -4606,6 +4606,7 @@ const message = {
isEdirWarn: 'docker-compose.yml ファイルの変更が検出されました。差分を確認してください。',
},
website: {
+ sslDomainMismatchWebsite: '証明書のドメインがウェブサイトのドメインと一致しません',
primaryDomain: 'プライマリドメイン',
otherDomains: '他のドメイン',
static: '静的',
diff --git a/frontend/src/lang/modules/ko.ts b/frontend/src/lang/modules/ko.ts
index e853e8a34..713e0c862 100644
--- a/frontend/src/lang/modules/ko.ts
+++ b/frontend/src/lang/modules/ko.ts
@@ -4524,6 +4524,7 @@ const message = {
isEdirWarn: 'docker-compose.yml 파일 변경이 감지되었습니다. 차이점을 확인해 주세요.',
},
website: {
+ sslDomainMismatchWebsite: '인증서 도메인이 웹사이트 도메인과 일치하지 않습니다',
primaryDomain: '기본 도메인',
otherDomains: '기타 도메인',
static: '정적',
diff --git a/frontend/src/lang/modules/lo.ts b/frontend/src/lang/modules/lo.ts
index 00a1d238a..c8f587c81 100644
--- a/frontend/src/lang/modules/lo.ts
+++ b/frontend/src/lang/modules/lo.ts
@@ -4486,6 +4486,7 @@ const message = {
isEdirWarn: 'ກວດພົບການປ່ຽນແປງໃນ docker-compose.yml. ກະລຸນາກວດສອບຄວາມແຕກຕ່າງ.',
},
website: {
+ sslDomainMismatchWebsite: 'ໂດເມນຂອງໃບຢັ້ງຢືນບໍ່ກົງກັບໂດເມນຂອງເວັບໄຊ',
primaryDomain: 'ໂດເມນຫຼັກ',
otherDomains: 'ໂດເມນອື່ນໆ',
static: 'ສະແຕຕິກ (Static)',
diff --git a/frontend/src/lang/modules/ms.ts b/frontend/src/lang/modules/ms.ts
index d189ca40c..1ac77ffde 100644
--- a/frontend/src/lang/modules/ms.ts
+++ b/frontend/src/lang/modules/ms.ts
@@ -4695,6 +4695,7 @@ const message = {
isEdirWarn: 'Perubahan pada fail docker-compose.yml telah dikesan. Sila semak perbezaannya.',
},
website: {
+ sslDomainMismatchWebsite: 'Domain sijil tidak sepadan dengan domain laman web',
primaryDomain: 'Domain Utama',
otherDomains: 'Domain Lain',
static: 'Statik',
diff --git a/frontend/src/lang/modules/pt-br.ts b/frontend/src/lang/modules/pt-br.ts
index 4154cf1c8..b37ddb32c 100644
--- a/frontend/src/lang/modules/pt-br.ts
+++ b/frontend/src/lang/modules/pt-br.ts
@@ -4719,6 +4719,7 @@ const message = {
isEdirWarn: 'Foram detectadas alterações no arquivo docker-compose.yml. Revise a comparação.',
},
website: {
+ sslDomainMismatchWebsite: 'Os domínios do certificado não correspondem aos domínios do site',
primaryDomain: 'Domínio principal',
otherDomains: 'Outros domínios',
static: 'Estático',
diff --git a/frontend/src/lang/modules/ru.ts b/frontend/src/lang/modules/ru.ts
index 536bdd502..3f6d95b57 100644
--- a/frontend/src/lang/modules/ru.ts
+++ b/frontend/src/lang/modules/ru.ts
@@ -4689,6 +4689,7 @@ const message = {
isEdirWarn: 'Обнаружены изменения в файле docker-compose.yml. Проверьте различия.',
},
website: {
+ sslDomainMismatchWebsite: 'Домены сертификата не соответствуют доменам сайта',
primaryDomain: 'Основной домен',
otherDomains: 'Другие домены',
static: 'Статический',
diff --git a/frontend/src/lang/modules/tr.ts b/frontend/src/lang/modules/tr.ts
index b897ef03c..bba854de3 100644
--- a/frontend/src/lang/modules/tr.ts
+++ b/frontend/src/lang/modules/tr.ts
@@ -4697,6 +4697,7 @@ const message = {
isEdirWarn: 'docker-compose.yml dosyasında değişiklikler algılandı. Lütfen farkları inceleyin.',
},
website: {
+ sslDomainMismatchWebsite: 'Sertifika alan adları web sitesinin alan adlarıyla eşleşmiyor',
primaryDomain: 'Birincil alan adı',
otherDomains: 'Diğer alan adları',
static: 'Statik',
diff --git a/frontend/src/lang/modules/zh-Hant.ts b/frontend/src/lang/modules/zh-Hant.ts
index 6d2343847..a5a588035 100644
--- a/frontend/src/lang/modules/zh-Hant.ts
+++ b/frontend/src/lang/modules/zh-Hant.ts
@@ -4287,6 +4287,7 @@ const message = {
isEdirWarn: '偵測到 docker-compose.yml 檔案被修改,請檢視對比',
},
website: {
+ sslDomainMismatchWebsite: '憑證網域與網站網域不相符',
primaryDomain: '主域名',
otherDomains: '其他域名',
static: '靜態網站',
diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts
index f59acf7b8..c06d5f98b 100644
--- a/frontend/src/lang/modules/zh.ts
+++ b/frontend/src/lang/modules/zh.ts
@@ -4321,6 +4321,7 @@ const message = {
isEdirWarn: '检测到 docker-compose.yml 文件被修改,请查看对比',
},
website: {
+ sslDomainMismatchWebsite: '证书域名与网站域名不匹配',
primaryDomain: '主域名',
otherDomains: '其他域名',
static: '静态网站',
diff --git a/frontend/src/utils/ssl-domain.ts b/frontend/src/utils/ssl-domain.ts
new file mode 100644
index 000000000..41c986218
--- /dev/null
+++ b/frontend/src/utils/ssl-domain.ts
@@ -0,0 +1,47 @@
+interface CertificateDomains {
+ primaryDomain?: string;
+ domains?: string;
+}
+
+export function normalizeDomain(value = ''): string {
+ let host = value.trim().toLowerCase();
+ if (host.startsWith('[')) {
+ host = host.slice(1, host.indexOf(']'));
+ } else if ((host.match(/:/g) || []).length === 1) {
+ host = host.replace(/:\d+$/, '');
+ }
+ host = host.replace(/\.$/, '');
+ if (!host) return '';
+ try {
+ // URL normalizes internationalized hostnames and equivalent IPv6 spellings.
+ const normalized = new URL(`http://${host.includes(':') ? `[${host}]` : host}`).hostname;
+ return normalized.replace(/^\[|\]$/g, '');
+ } catch {
+ return '';
+ }
+}
+
+export function domainMatches(pattern: string, target: string): boolean {
+ pattern = normalizeDomain(pattern);
+ target = normalizeDomain(target);
+ if (!pattern || !target) return false;
+ if (pattern === target) return true;
+ if (!pattern.startsWith('*.') || target.includes(':') || /^\d+(\.\d+){3}$/.test(target)) return false;
+ return target.endsWith(pattern.slice(1)) && target.split('.').length === pattern.split('.').length;
+}
+
+export function getCertificateDomains(ssl: CertificateDomains): string[] {
+ return [
+ ...new Set(
+ [ssl.primaryDomain || '', ...(ssl.domains || '').split(/[,\s]+/)].map(normalizeDomain).filter(Boolean),
+ ),
+ ];
+}
+
+export function certificateDomainMismatch(domains: string[], ssl?: CertificateDomains): boolean {
+ if (!ssl) return false;
+ const patterns = getCertificateDomains(ssl);
+ const hosts = domains.map(normalizeDomain).filter(Boolean);
+ if (!patterns.length || !hosts.length) return false;
+ return hosts.some((host) => !patterns.some((pattern) => domainMatches(pattern, host)));
+}
diff --git a/frontend/src/views/website/website/components/https/index.vue b/frontend/src/views/website/website/components/https/index.vue
index 0ef246f1e..5845ab359 100644
--- a/frontend/src/views/website/website/components/https/index.vue
+++ b/frontend/src/views/website/website/components/https/index.vue
@@ -77,6 +77,9 @@
+
+ {{ $t('website.sslDomainMismatchWebsite') }}
+
@@ -147,6 +150,7 @@