From b97f024f8ab27f816068050c0fd73c5df5d285a0 Mon Sep 17 00:00:00 2001 From: Herman Slatman Date: Fri, 26 Mar 2021 14:02:52 +0100 Subject: [PATCH] Remove superfluous call to StoreCertificate --- ca/ca.go | 1 - scep/authority.go | 13 ------------- scep/certificate.go | 21 --------------------- scep/errors.go | 7 ------- 4 files changed, 42 deletions(-) delete mode 100644 scep/certificate.go diff --git a/ca/ca.go b/ca/ca.go index 4d268c5b..95ee6f26 100644 --- a/ca/ca.go +++ b/ca/ca.go @@ -152,7 +152,6 @@ func (ca *CA) Init(config *authority.Config) (*CA, error) { scepPrefix := "scep" scepAuthority, err := scep.New(auth, scep.AuthorityOptions{ Service: auth.GetSCEPService(), - DB: auth.GetDatabase().(scep.DB), DNS: dns, Prefix: scepPrefix, }) diff --git a/scep/authority.go b/scep/authority.go index c73885e5..9a0a2058 100644 --- a/scep/authority.go +++ b/scep/authority.go @@ -34,7 +34,6 @@ type Interface interface { // Authority is the layer that handles all SCEP interactions. type Authority struct { - db DB prefix string dns string intermediateCertificate *x509.Certificate @@ -46,8 +45,6 @@ type Authority struct { type AuthorityOptions struct { // Service provides the certificate chain, the signer and the decrypter to the Authority Service *Service - // DB is the database used by SCEP - DB DB // DNS is the host used to generate accurate SCEP links. By default the authority // will use the Host from the request, so this value will only be used if // request.Host is empty. @@ -67,7 +64,6 @@ type SignAuthority interface { func New(signAuth SignAuthority, ops AuthorityOptions) (*Authority, error) { authority := &Authority{ - db: ops.DB, prefix: ops.Prefix, dns: ops.DNS, signAuth: signAuth, @@ -341,15 +337,6 @@ func (a *Authority) SignCSR(ctx context.Context, csr *x509.CertificateRequest, m CertRepMessage: cr, } - // store the newly created certificate - err = newCert(a.db, CertOptions{ - Leaf: certChain[0], - Intermediates: certChain[1:], - }) - if err != nil { - return nil, err - } - return crepMsg, nil } diff --git a/scep/certificate.go b/scep/certificate.go deleted file mode 100644 index 39015af5..00000000 --- a/scep/certificate.go +++ /dev/null @@ -1,21 +0,0 @@ -package scep - -import ( - "crypto/x509" - - "github.com/pkg/errors" -) - -// CertOptions options with which to create and store a cert object. -type CertOptions struct { - Leaf *x509.Certificate - Intermediates []*x509.Certificate -} - -func newCert(db DB, ops CertOptions) error { - err := db.StoreCertificate(ops.Leaf) - if err != nil { - errors.Wrap(err, "error while storing certificate") - } - return nil -} diff --git a/scep/errors.go b/scep/errors.go index 8454e16d..4287403b 100644 --- a/scep/errors.go +++ b/scep/errors.go @@ -2,18 +2,11 @@ package scep // Error is an SCEP error type type Error struct { - // Type ProbType - // Detail string Message string `json:"message"` Status int `json:"-"` - // Sub []*Error - // Identifier *Identifier } // Error implements the error interface. func (e *Error) Error() string { - // if e.Err == nil { - // return e.Detail - // } return e.Message }