WithRemoveExpiredCerts will remove the expired certificates automatically.
(t time.Time)
| 63 | |
| 64 | // WithRemoveExpiredCerts will remove the expired certificates automatically. |
| 65 | func WithRemoveExpiredCerts(t time.Time) AgentOption { |
| 66 | unixNow := t.Unix() |
| 67 | return func(o *options) { |
| 68 | o.removeExpiredKey = func(a *Agent, k *agent.Key) bool { |
| 69 | if cert, err := ParseCertificate(k.Marshal()); err == nil { |
| 70 | if before := cast.Int64(cert.ValidBefore); cert.ValidBefore != uint64(ssh.CertTimeInfinity) && (unixNow >= before || before < 0) { |
| 71 | if err := a.Remove(k); err == nil { |
| 72 | return true |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | return false |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | // ErrNotFound is the error returned if a something is not found. |
| 82 | var ErrNotFound = errors.New("not found") |
no test coverage detected
searching dependent graphs…