cmd/ca-signed: clean up the codebase

This commit is contained in:
2025-11-18 23:01:58 -08:00
parent 7f3f513bdd
commit ff34eb4eff
2 changed files with 81 additions and 199 deletions

View File

@@ -4,6 +4,7 @@ import (
"crypto/x509"
"encoding/pem"
"errors"
"fmt"
"os"
"git.wntrmute.dev/kyle/goutils/certlib/certerr"
@@ -93,3 +94,18 @@ func LoadCertificates(path string) ([]*x509.Certificate, error) {
return ReadCertificates(in)
}
func PoolFromBytes(certBytes []byte) (*x509.CertPool, error) {
pool := x509.NewCertPool()
certs, err := ReadCertificates(certBytes)
if err != nil {
return nil, fmt.Errorf("failed to read certificates: %w", err)
}
for _, cert := range certs {
pool.AddCert(cert)
}
return pool, nil
}