Skip to content

Commit

Permalink
Add cert pool function
Browse files Browse the repository at this point in the history
  • Loading branch information
Phisto committed Jan 9, 2024
1 parent 593782d commit ff3b1a6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions festivalspki.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,17 @@ func LoadX509Certificate(certFile string) (*x509.Certificate, error) {
}
return cert, nil
}

// Creates and returns a certificate pool with the given certificate added to it.
func LoadCertificatePool(certFile string) (*x509.CertPool, error) {

rootCertPool := x509.NewCertPool()
certContent, err := os.ReadFile(certFile)
if err != nil {
return nil, err
}
if ok := rootCertPool.AppendCertsFromPEM(certContent); !ok {
return nil, errors.New("Failed to append certificate to certificate pool.")
}
return rootCertPool, nil
}

0 comments on commit ff3b1a6

Please sign in to comment.