mirror of
https://github.com/usual2970/certimate.git
synced 2025-10-04 21:44:54 +00:00
refactor: clean code
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/go-acme/lego/v4/registration"
|
||||
|
||||
"github.com/usual2970/certimate/internal/domain"
|
||||
"github.com/usual2970/certimate/internal/pkg/utils/x509"
|
||||
"github.com/usual2970/certimate/internal/pkg/utils/certs"
|
||||
"github.com/usual2970/certimate/internal/repository"
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ func newAcmeUser(ca, email string) (*acmeUser, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
keyPEM, err := x509.ConvertECPrivateKeyToPEM(key)
|
||||
keyPEM, err := certs.ConvertECPrivateKeyToPEM(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (u acmeUser) GetRegistration() *registration.Resource {
|
||||
}
|
||||
|
||||
func (u *acmeUser) GetPrivateKey() crypto.PrivateKey {
|
||||
rs, _ := x509.ParseECPrivateKeyFromPEM(u.privkey)
|
||||
rs, _ := certs.ParseECPrivateKeyFromPEM(u.privkey)
|
||||
return rs
|
||||
}
|
||||
|
||||
|
@@ -20,12 +20,12 @@ import (
|
||||
)
|
||||
|
||||
type ApplyCertResult struct {
|
||||
CertificateChain string
|
||||
IssuerCertificate string
|
||||
PrivateKey string
|
||||
ACMECertUrl string
|
||||
ACMECertStableUrl string
|
||||
CSR string
|
||||
CertificateFullChain string
|
||||
IssuerCertificate string
|
||||
PrivateKey string
|
||||
ACMECertUrl string
|
||||
ACMECertStableUrl string
|
||||
CSR string
|
||||
}
|
||||
|
||||
type Applicant interface {
|
||||
@@ -150,12 +150,12 @@ func apply(challengeProvider challenge.Provider, options *applicantOptions) (*Ap
|
||||
}
|
||||
|
||||
return &ApplyCertResult{
|
||||
CertificateChain: strings.TrimSpace(string(certResource.Certificate)),
|
||||
IssuerCertificate: strings.TrimSpace(string(certResource.IssuerCertificate)),
|
||||
PrivateKey: strings.TrimSpace(string(certResource.PrivateKey)),
|
||||
ACMECertUrl: certResource.CertURL,
|
||||
ACMECertStableUrl: certResource.CertStableURL,
|
||||
CSR: string(certResource.CSR),
|
||||
CertificateFullChain: strings.TrimSpace(string(certResource.Certificate)),
|
||||
IssuerCertificate: strings.TrimSpace(string(certResource.IssuerCertificate)),
|
||||
PrivateKey: strings.TrimSpace(string(certResource.PrivateKey)),
|
||||
ACMECertUrl: certResource.CertURL,
|
||||
ACMECertStableUrl: certResource.CertStableURL,
|
||||
CSR: string(certResource.CSR),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user