Skip to content
Snippets Groups Projects
Commit 1fd3ac5d authored by Niall Sheridan's avatar Niall Sheridan
Browse files

Set an expiry on keys added to the agent

parent a52d19e9
No related branches found
No related tags found
No related merge requests found
...@@ -31,10 +31,12 @@ var ( ...@@ -31,10 +31,12 @@ var (
) )
func installCert(a agent.Agent, cert *ssh.Certificate, key key) error { func installCert(a agent.Agent, cert *ssh.Certificate, key key) error {
lifetime := time.Unix(int64(cert.ValidBefore), 0).Sub(time.Now()).Seconds()
pubcert := agent.AddedKey{ pubcert := agent.AddedKey{
PrivateKey: key, PrivateKey: key,
Certificate: cert, Certificate: cert,
Comment: cert.KeyId, Comment: cert.KeyId,
LifetimeSecs: uint32(lifetime),
} }
if err := a.Add(pubcert); err != nil { if err := a.Add(pubcert); err != nil {
return fmt.Errorf("error importing certificate: %s", err) return fmt.Errorf("error importing certificate: %s", err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment