MCPcopy
hub / github.com/smallstep/cli / WithRemoveExpiredCerts

Function WithRemoveExpiredCerts

internal/sshutil/agent.go:65–79  ·  view source on GitHub ↗

WithRemoveExpiredCerts will remove the expired certificates automatically.

(t time.Time)

Source from the content-addressed store, hash-verified

63
64// WithRemoveExpiredCerts will remove the expired certificates automatically.
65func 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.
82var ErrNotFound = errors.New("not found")

Callers 2

doLoginIfNeededFunction · 0.92
loginActionFunction · 0.92

Calls 2

Int64Function · 0.92
ParseCertificateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…