fix: parse ssl certificate error #270

This commit is contained in:
0xJacky 2024-02-06 15:41:36 +08:00
parent e1c38e28a8
commit 371472e67b
No known key found for this signature in database
GPG key ID: B6E4A6E4A561BAF0
5 changed files with 16 additions and 17 deletions

View file

@ -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"`