fix: remove unnecessary string checks for key file in Upload method

This commit is contained in:
GitHub Actions
2026-04-13 13:56:59 +00:00
parent f3c33dc81b
commit 3005db6943

View File

@@ -5,7 +5,6 @@ import (
"io"
"net/http"
"strconv"
"strings"
"sync"
"time"
@@ -120,7 +119,7 @@ func (h *CertificateHandler) Upload(c *gin.Context) {
}
certPEM := string(certBytes)
// Read private key file (optional for PFX)
// Read private key file (optional format detection is content-based in the service)
var keyPEM string
keyFile, err := c.FormFile("key_file")
if err == nil {
@@ -141,10 +140,6 @@ func (h *CertificateHandler) Upload(c *gin.Context) {
return
}
keyPEM = string(keyBytes)
} else if !strings.HasSuffix(strings.ToLower(certFile.Filename), ".pfx") &&
!strings.HasSuffix(strings.ToLower(certFile.Filename), ".p12") {
c.JSON(http.StatusBadRequest, gin.H{"error": "key_file is required for PEM certificates"})
return
}
// Read chain file (optional)