Added function that can look for a certificate in the database.
This commit is contained in:
28
certdb.go
28
certdb.go
@@ -34,6 +34,34 @@ type CertificateRecord struct {
|
||||
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 {
|
||||
// return filepath.Join(filepath.Dir(caConfigPath), caConfig.GetStateFileName())
|
||||
// }
|
||||
|
Reference in New Issue
Block a user