Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hslatman committed Mar 10, 2021
1 parent cc1ecb9 commit 538fe81
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 37 deletions.
3 changes: 3 additions & 0 deletions authority/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ func (a *Authority) init() error {
DecryptionKey: a.config.IntermediateKey,
Password: []byte(a.config.Password),
})
if err != nil {
return err
}
}

a.scepService = &scep.Service{
Expand Down
7 changes: 0 additions & 7 deletions scep/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,6 @@ func (h *Handler) PKIOperation(ctx context.Context, request SCEPRequest) (SCEPRe
return response, nil
}

func certName(cert *x509.Certificate) string {
if cert.Subject.CommonName != "" {
return cert.Subject.CommonName
}
return string(cert.Signature)
}

func formatCapabilities(caps []string) []byte {
return []byte(strings.Join(caps, "\r\n"))
}
Expand Down
16 changes: 0 additions & 16 deletions scep/authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package scep
import (
"bytes"
"context"
"crypto"
"crypto/sha1"
"crypto/x509"
"errors"
"fmt"
Expand Down Expand Up @@ -512,20 +510,6 @@ func degenerateCertificates(certs []*x509.Certificate) ([]byte, error) {
return degenerate, nil
}

// createKeyIdentifier creates an identifier for public keys
// according to the first method in RFC5280 section 4.2.1.2.
func createKeyIdentifier(pub crypto.PublicKey) ([]byte, error) {

keyBytes, err := x509.MarshalPKIXPublicKey(pub)
if err != nil {
return nil, err
}

id := sha1.Sum(keyBytes)

return id[:], nil
}

// Interface guards
var (
_ Interface = (*Authority)(nil)
Expand Down
26 changes: 13 additions & 13 deletions scep/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ func newCert(db nosql.DB, ops CertOptions) (*certificate, error) {
}
}

func getCert(db nosql.DB, id string) (*certificate, error) {
b, err := db.Get(certTable, []byte(id))
if nosql.IsErrNotFound(err) {
return nil, fmt.Errorf("certificate %s not found", id)
} else if err != nil {
return nil, fmt.Errorf("error loading certificate")
}
var cert certificate
if err := json.Unmarshal(b, &cert); err != nil {
return nil, fmt.Errorf("%w: error unmarshaling certificate", err)
}
return &cert, nil
}
// func getCert(db nosql.DB, id string) (*certificate, error) {
// b, err := db.Get(certTable, []byte(id))
// if nosql.IsErrNotFound(err) {
// return nil, fmt.Errorf("certificate %s not found", id)
// } else if err != nil {
// return nil, fmt.Errorf("error loading certificate")
// }
// var cert certificate
// if err := json.Unmarshal(b, &cert); err != nil {
// return nil, fmt.Errorf("%w: error unmarshaling certificate", err)
// }
// return &cert, nil
// }
3 changes: 2 additions & 1 deletion scep/scep.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ var (
oidSCEPsenderNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 5}
oidSCEPrecipientNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 6}
oidSCEPtransactionID = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 7}
oidChallengePassword = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 7}
oidSCEPfailInfoText = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 24}
//oidChallengePassword = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 7}

)

// PKIMessage defines the possible SCEP message types
Expand Down

0 comments on commit 538fe81

Please sign in to comment.