mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-26 09:54:21 +00:00
Remove tlsconfigutil.CABundle.IsEqual and ensure that tlsconfigutil.NewCABundle handles nil/empty input
Co-authored-by: Ryan Richard <richardry@vmware.com>
This commit is contained in:
committed by
Ryan Richard
co-authored by
Ryan Richard
parent
fcceeed9fa
commit
99cfc4fbce
@@ -16,12 +16,19 @@ type CABundle struct {
|
||||
}
|
||||
|
||||
func NewCABundle(caBundle []byte) (*CABundle, bool) {
|
||||
certPool := x509.NewCertPool()
|
||||
var certPool *x509.CertPool
|
||||
ok := true
|
||||
|
||||
if len(caBundle) > 0 {
|
||||
certPool = x509.NewCertPool()
|
||||
ok = certPool.AppendCertsFromPEM(caBundle)
|
||||
}
|
||||
|
||||
return &CABundle{
|
||||
caBundle: caBundle,
|
||||
sha256: sha256.Sum256(caBundle),
|
||||
certPool: certPool,
|
||||
}, certPool.AppendCertsFromPEM(caBundle)
|
||||
}, ok
|
||||
}
|
||||
|
||||
// PEMBytes returns the CA certificate bundle PEM bytes.
|
||||
@@ -59,8 +66,3 @@ func (c *CABundle) Hash() [32]byte {
|
||||
}
|
||||
return c.sha256 // note that this will always return the same hash for nil input
|
||||
}
|
||||
|
||||
// IsEqual returns whether a CABundle has the same CA certificate bundle as another.
|
||||
func (c *CABundle) IsEqual(other *CABundle) bool {
|
||||
return c.Hash() == other.Hash()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user