mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
feat(site): allow to use cert selector to change cert when site is disabled
This commit is contained in:
parent
0cd0761e33
commit
9401bcc242
3 changed files with 26 additions and 12 deletions
|
@ -8,6 +8,7 @@ const props = defineProps<{
|
|||
configName: string
|
||||
currentServerIndex: number
|
||||
certInfo?: CertificateInfo[]
|
||||
siteEnabled: boolean
|
||||
}>()
|
||||
|
||||
const enabled = defineModel<boolean>('enabled', {
|
||||
|
@ -68,6 +69,7 @@ function handleCertChange(certs: Cert[]) {
|
|||
<ChangeCert @change="handleCertChange" />
|
||||
|
||||
<IssueCert
|
||||
v-if="siteEnabled"
|
||||
v-model:enabled="enabled"
|
||||
:config-name="configName"
|
||||
/>
|
||||
|
|
|
@ -120,15 +120,15 @@ provide('ngx_directives', ngx_directives)
|
|||
/>
|
||||
|
||||
<div class="tab-content">
|
||||
<template v-if="current_support_ssl && enabled">
|
||||
<Cert
|
||||
v-if="current_support_ssl"
|
||||
v-model:enabled="autoCert"
|
||||
:config-name="ngx_config.name"
|
||||
:cert-info="certInfo?.[k]"
|
||||
:current-server-index="current_server_index"
|
||||
/>
|
||||
</template>
|
||||
<Cert
|
||||
v-if="current_support_ssl"
|
||||
v-model:enabled="autoCert"
|
||||
class="mb-4"
|
||||
:site-enabled="enabled"
|
||||
:config-name="ngx_config.name"
|
||||
:cert-info="certInfo?.[k]"
|
||||
:current-server-index="current_server_index"
|
||||
/>
|
||||
|
||||
<template v-if="v.comments">
|
||||
<h3>{{ $gettext('Comments') }}</h3>
|
||||
|
|
|
@ -3,10 +3,11 @@ package cert
|
|||
import (
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
|
@ -39,8 +40,19 @@ func GetCertInfo(sslCertificatePath string) (info *Info, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// for wildcard certificate, the subject name is the first DNS name
|
||||
subjectName := cert.Subject.CommonName
|
||||
if subjectName == "" {
|
||||
for _, name := range cert.DNSNames {
|
||||
if name != "" {
|
||||
subjectName = name
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info = &Info{
|
||||
SubjectName: cert.Subject.CommonName,
|
||||
SubjectName: subjectName,
|
||||
IssuerName: cert.Issuer.CommonName,
|
||||
NotAfter: cert.NotAfter,
|
||||
NotBefore: cert.NotBefore,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue