Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
Signed-off-by: Slavek Kabrda <[email protected]>
  • Loading branch information
bkabrda committed Aug 28, 2024
1 parent 1b686a2 commit f1e85bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package repo

import (
"archive/tar"
"bytes"
"compress/gzip"
"context"
"crypto"
Expand Down Expand Up @@ -347,13 +348,14 @@ func getKeyWithDetails(key []byte) (crypto.PublicKey, crypto.Hash, error) {
func certChainToCertificateAuthority(certChainPem []byte) (*root.CertificateAuthority, error) {
var cert *x509.Certificate
var err error
rest := certChainPem
rest := bytes.TrimSpace(certChainPem)
certChain := []*x509.Certificate{}

// skip potential whitespace at end of file (8 is kinda random, but seems to work fine)
for len(rest) > 8 {
for len(rest) > 0 {
var derCert *pem.Block
derCert, rest = pem.Decode(rest)
rest = bytes.TrimSpace(rest)
if derCert == nil {
return nil, fmt.Errorf("input is left, but it is not a certificate: %+v", rest)
}
Expand Down

0 comments on commit f1e85bf

Please sign in to comment.