mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-08 05:29:51 +00:00
parse privatekey using certcrypto
This commit is contained in:
parent
1039591677
commit
101d77e4ae
@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
"github.com/usual2970/certimate/internal/app"
|
||||
"github.com/usual2970/certimate/internal/domain"
|
||||
"github.com/usual2970/certimate/internal/domain/dtos"
|
||||
@ -194,13 +195,8 @@ func (s *CertificateService) ValidateCertificate(ctx context.Context, req *dtos.
|
||||
}
|
||||
|
||||
func (s *CertificateService) ValidatePrivateKey(ctx context.Context, req *dtos.CertificateValidatePrivateKeyReq) error {
|
||||
if strings.Contains(req.PrivateKey, "-----BEGIN RSA PRIVATE KEY-----") {
|
||||
_, err := certs.ParsePKCS1PrivateKeyFromPEM(req.PrivateKey)
|
||||
return err
|
||||
} else {
|
||||
_, err := certs.ParseECPrivateKeyFromPEM(req.PrivateKey)
|
||||
return err
|
||||
}
|
||||
_, err := certcrypto.ParsePEMPrivateKey([]byte(req.PrivateKey))
|
||||
return err
|
||||
}
|
||||
|
||||
func buildExpireSoonNotification(certificates []*domain.Certificate) *struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user