Added function that can look for a certificate in the database.

This commit is contained in:
2025-07-28 18:57:57 +02:00
parent b387a016be
commit 9b7b995e97

View File

@@ -34,6 +34,34 @@ type CertificateRecord struct {
RevokeReason int `json:"revokeReason,omitempty"` RevokeReason int `json:"revokeReason,omitempty"`
} }
// Look for a certifcate by its name
func (c *CAState) FindByName(name string, all bool) *CertificateRecord {
for _, cert := range c.Certificates {
if cert.RevokedAt != "" && !all {
continue
}
if cert.Name == name {
return &cert
}
}
return nil
}
// Look for a certificate by its serial
func (c *CAState) FindBySerial(serial string, all bool) *CertificateRecord {
for _, cert := range c.Certificates {
if cert.RevokedAt != "" && !all {
continue
}
if cert.Serial == serial {
return &cert
}
}
return nil
}
// func caStatePath() string { // func caStatePath() string {
// return filepath.Join(filepath.Dir(caConfigPath), caConfig.GetStateFileName()) // return filepath.Join(filepath.Dir(caConfigPath), caConfig.GetStateFileName())
// } // }