From 371472e67bb8452f861ea0c88db88c58c7e783d0 Mon Sep 17 00:00:00 2001 From: 0xJacky Date: Tue, 6 Feb 2024 15:41:36 +0800 Subject: [PATCH] fix: parse ssl certificate error #270 --- api/certificate/certificate.go | 6 +++--- app/src/views/certificate/CertificateEditor.vue | 4 ++-- internal/cert/helper.go | 11 +++++------ internal/validation/certificate.go | 8 ++++---- internal/validation/validation.go | 4 ++-- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/api/certificate/certificate.go b/api/certificate/certificate.go index b2351bc1..62cd47fb 100644 --- a/api/certificate/certificate.go +++ b/api/certificate/certificate.go @@ -25,7 +25,7 @@ func Transformer(certModel *model.Cert) (certificate *APICertificate) { if certModel.SSLCertificatePath != "" { if _, err := os.Stat(certModel.SSLCertificatePath); err == nil { sslCertificationBytes, _ = os.ReadFile(certModel.SSLCertificatePath) - if !cert.IsPublicKey(string(sslCertificationBytes)) { + if !cert.IsCertificate(string(sslCertificationBytes)) { sslCertificationBytes = []byte{} } } @@ -77,9 +77,9 @@ func GetCert(c *gin.Context) { type certJson struct { Name string `json:"name" binding:"required"` - SSLCertificatePath string `json:"ssl_certificate_path" binding:"required,publickey_path"` + SSLCertificatePath string `json:"ssl_certificate_path" binding:"required,certificate_path"` SSLCertificateKeyPath string `json:"ssl_certificate_key_path" binding:"required,privatekey_path"` - SSLCertificate string `json:"ssl_certificate" binding:"omitempty,publickey"` + SSLCertificate string `json:"ssl_certificate" binding:"omitempty,certificate"` SSLCertificateKey string `json:"ssl_certificate_key" binding:"omitempty,privatekey"` ChallengeMethod string `json:"challenge_method"` DnsCredentialID int `json:"dns_credential_id"` diff --git a/app/src/views/certificate/CertificateEditor.vue b/app/src/views/certificate/CertificateEditor.vue index 158d9748..c00e243f 100644 --- a/app/src/views/certificate/CertificateEditor.vue +++ b/app/src/views/certificate/CertificateEditor.vue @@ -164,7 +164,7 @@ const isManaged = computed(() => { :label="$gettext('SSL Certificate Path')" :validate-status="errors.ssl_certificate_path ? 'error' : ''" :help="errors.ssl_certificate_path === 'required' ? $gettext('This field is required') - : errors.ssl_certificate_path === 'publickey_path' + : errors.ssl_certificate_path === 'certificate_path' ? $gettext('The path exists, but the file is not a public key') : ''" >

@@ -193,7 +193,7 @@ const isManaged = computed(() => {