Skip to content

Commit

Permalink
Add function GetAllCertificates (#149)
Browse files Browse the repository at this point in the history
This would returns latest loaded certs

Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
  • Loading branch information
shtripat authored Jan 8, 2025
1 parent 9e9b477 commit 8cc578c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions certs/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,24 @@ func isSymlink(file string) (bool, error) {
}
return st.Mode()&os.ModeSymlink == os.ModeSymlink, nil
}

// GetAllCertificates returns all the certificates loaded
func (m *Manager) GetAllCertificates() []*x509.Certificate {
m.lock.RLock()
defer m.lock.RUnlock()

certs := []*x509.Certificate{}
for _, c := range m.certificates {
if c.Leaf != nil {
// marshal and parse to create a deep copy
cBytes := c.Leaf.Raw
copyCert, err := x509.ParseCertificate(cBytes)
if err != nil {
continue
}
certs = append(certs, copyCert)
}
}

return certs
}

0 comments on commit 8cc578c

Please sign in to comment.