From 782d895d8d6e66938a3fa6914d8e93a79c949771 Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Fri, 27 Nov 2020 17:13:41 +0100 Subject: added ParseDerChain tests --- x509util/x509util.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'x509util/x509util.go') diff --git a/x509util/x509util.go b/x509util/x509util.go index f95b136..c3ebd4b 100644 --- a/x509util/x509util.go +++ b/x509util/x509util.go @@ -104,8 +104,11 @@ func NewEd25519PrivateKey(data []byte) (ed25519.PrivateKey, error) { // the remaining ones as its intermediate CertPool. func ParseDerChain(chain [][]byte) (*x509.Certificate, *x509.CertPool, error) { certificates, err := ParseDerList(chain) - if err != nil || len(certificates) == 0 { - return nil, nil, err // TODO: don't think the len check works now.. + if err != nil { + return nil, nil, err + } + if len(certificates) == 0 { + return nil, nil, fmt.Errorf("empty certificate chain") } intermediatePool := x509.NewCertPool() for _, certificate := range certificates[1:] { -- cgit v1.2.3