mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15: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
|
configName: string
|
||||||
currentServerIndex: number
|
currentServerIndex: number
|
||||||
certInfo?: CertificateInfo[]
|
certInfo?: CertificateInfo[]
|
||||||
|
siteEnabled: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const enabled = defineModel<boolean>('enabled', {
|
const enabled = defineModel<boolean>('enabled', {
|
||||||
|
@ -68,6 +69,7 @@ function handleCertChange(certs: Cert[]) {
|
||||||
<ChangeCert @change="handleCertChange" />
|
<ChangeCert @change="handleCertChange" />
|
||||||
|
|
||||||
<IssueCert
|
<IssueCert
|
||||||
|
v-if="siteEnabled"
|
||||||
v-model:enabled="enabled"
|
v-model:enabled="enabled"
|
||||||
:config-name="configName"
|
:config-name="configName"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -120,15 +120,15 @@ provide('ngx_directives', ngx_directives)
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<template v-if="current_support_ssl && enabled">
|
<Cert
|
||||||
<Cert
|
v-if="current_support_ssl"
|
||||||
v-if="current_support_ssl"
|
v-model:enabled="autoCert"
|
||||||
v-model:enabled="autoCert"
|
class="mb-4"
|
||||||
:config-name="ngx_config.name"
|
:site-enabled="enabled"
|
||||||
:cert-info="certInfo?.[k]"
|
:config-name="ngx_config.name"
|
||||||
:current-server-index="current_server_index"
|
:cert-info="certInfo?.[k]"
|
||||||
/>
|
:current-server-index="current_server_index"
|
||||||
</template>
|
/>
|
||||||
|
|
||||||
<template v-if="v.comments">
|
<template v-if="v.comments">
|
||||||
<h3>{{ $gettext('Comments') }}</h3>
|
<h3>{{ $gettext('Comments') }}</h3>
|
||||||
|
|
|
@ -3,10 +3,11 @@ package cert
|
||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
|
||||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||||
|
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
|
@ -39,8 +40,19 @@ func GetCertInfo(sslCertificatePath string) (info *Info, err error) {
|
||||||
return
|
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{
|
info = &Info{
|
||||||
SubjectName: cert.Subject.CommonName,
|
SubjectName: subjectName,
|
||||||
IssuerName: cert.Issuer.CommonName,
|
IssuerName: cert.Issuer.CommonName,
|
||||||
NotAfter: cert.NotAfter,
|
NotAfter: cert.NotAfter,
|
||||||
NotBefore: cert.NotBefore,
|
NotBefore: cert.NotBefore,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue