mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat: using renewal api to renew certificate #319
This commit is contained in:
parent
e3876cffaf
commit
e16b077d20
11 changed files with 173 additions and 71 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
"github.com/lib/pq"
|
||||
"os"
|
||||
)
|
||||
|
@ -17,21 +18,30 @@ const (
|
|||
|
||||
type CertDomains []string
|
||||
|
||||
type CertificateResource struct {
|
||||
*certificate.Resource
|
||||
PrivateKey []byte `json:"private_key"`
|
||||
Certificate []byte `json:"certificate"`
|
||||
IssuerCertificate []byte `json:"issuerCertificate"`
|
||||
CSR []byte `json:"csr"`
|
||||
}
|
||||
|
||||
type Cert struct {
|
||||
Model
|
||||
Name string `json:"name"`
|
||||
Domains pq.StringArray `json:"domains" gorm:"type:text[]"`
|
||||
Filename string `json:"filename"`
|
||||
SSLCertificatePath string `json:"ssl_certificate_path"`
|
||||
SSLCertificateKeyPath string `json:"ssl_certificate_key_path"`
|
||||
AutoCert int `json:"auto_cert"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DnsCredentialID int `json:"dns_credential_id"`
|
||||
DnsCredential *DnsCredential `json:"dns_credential,omitempty"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
ACMEUser *AcmeUser `json:"acme_user,omitempty"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
Log string `json:"log"`
|
||||
Name string `json:"name"`
|
||||
Domains pq.StringArray `json:"domains" gorm:"type:text[]"`
|
||||
Filename string `json:"filename"`
|
||||
SSLCertificatePath string `json:"ssl_certificate_path"`
|
||||
SSLCertificateKeyPath string `json:"ssl_certificate_key_path"`
|
||||
AutoCert int `json:"auto_cert"`
|
||||
ChallengeMethod string `json:"challenge_method"`
|
||||
DnsCredentialID int `json:"dns_credential_id"`
|
||||
DnsCredential *DnsCredential `json:"dns_credential,omitempty"`
|
||||
ACMEUserID int `json:"acme_user_id"`
|
||||
ACMEUser *AcmeUser `json:"acme_user,omitempty"`
|
||||
KeyType certcrypto.KeyType `json:"key_type"`
|
||||
Log string `json:"log"`
|
||||
Resource *CertificateResource `json:"-" gorm:"serializer:json"`
|
||||
}
|
||||
|
||||
func FirstCert(confName string) (c Cert, err error) {
|
||||
|
@ -99,3 +109,15 @@ func (c *Cert) Remove() error {
|
|||
func (c *Cert) GetKeyType() certcrypto.KeyType {
|
||||
return helper.GetKeyType(c.KeyType)
|
||||
}
|
||||
|
||||
func (c *CertificateResource) GetResource() certificate.Resource {
|
||||
return certificate.Resource{
|
||||
Domain: c.Resource.Domain,
|
||||
CertURL: c.Resource.CertURL,
|
||||
CertStableURL: c.Resource.CertStableURL,
|
||||
PrivateKey: c.PrivateKey,
|
||||
Certificate: c.Certificate,
|
||||
IssuerCertificate: c.IssuerCertificate,
|
||||
CSR: c.CSR,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue