Herman Slatman 5 лет назад
Родитель
Сommit
e7cb80f880
5 измененных файлов с 18 добавлено и 37 удалено
  1. 3 0
      authority/authority.go
  2. 0 7
      scep/api/api.go
  3. 0 16
      scep/authority.go
  4. 13 13
      scep/certificate.go
  5. 2 1
      scep/scep.go

+ 3 - 0
authority/authority.go

@@ -337,6 +337,9 @@ func (a *Authority) init() error {
 				DecryptionKey: a.config.IntermediateKey,
 				Password:      []byte(a.config.Password),
 			})
+			if err != nil {
+				return err
+			}
 		}
 
 		a.scepService = &scep.Service{

+ 0 - 7
scep/api/api.go

@@ -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"))
 }

+ 0 - 16
scep/authority.go

@@ -3,8 +3,6 @@ package scep
 import (
 	"bytes"
 	"context"
-	"crypto"
-	"crypto/sha1"
 	"crypto/x509"
 	"errors"
 	"fmt"
@@ -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)

+ 13 - 13
scep/certificate.go

@@ -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
+// }

+ 2 - 1
scep/scep.go

@@ -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