Repository navigation
Conversation
|
Whats the |
| } | ||
|
|
||
| // certificate returns the certificate k carries, or nil. | ||
| func certificate(k key.SSHTPMKeys) *ssh.Certificate { |
There was a problem hiding this comment.
key.SSHTPMKeys has a pointer Certificate field. Why are we parsing the k.AgentKey().Blob for the *ssh.Certificate struct?
ssh-tpm-agent parsed the lifetime constraint of SSH_AGENTC_ADD_ID_CONSTRAINED and of tpm-add-key and dropped it. Keep it as the expiry of the key and, like the reaper of ssh-agent(1), delete the keys whose lifetime has run out before listing, signing or removing.
Renewing a short-lived certificate adds the new one next to the old, and the agent keeps the old one until it is removed: ssh offers them in order, and the server cuts the connection at MaxAuthTries before it gets to a valid one. ssh-add(1) avoids that client-side: it adds a certificate with a lifetime that ends CERT_EXPIRY_GRACE (five minutes) after its ValidBefore, so the agent deletes it, and ignores one already past that. Do the same, with -N to add certificates without a lifetime, as ssh-add -N does.
No, actually. So if we were to follow what |
|
Then again, it is on your TODO :) ssh-tpm-agent/agent/gocrypto.go Lines 62 to 64 in a9d3ab3 |
d77b788 to
55e0315
Compare
Renewing a short-lived certificate adds the new one next to the old: the agent only replaces an identical key, and for a key with a certificate that is the whole certificate blob. Unless the client removes the old certificate itself, expired ones pile up, ssh offers them in order, and the server cuts the connection at MaxAuthTries before it gets to the valid one.
Drop keys whose certificate is past its ValidBefore before listing them or looking up a signer, so expired certificates are never offered and never sign. Keys without a certificate, and certificates without an expiry, are untouched.
The test certificates of keytest had ValidBefore 0, which is expired; they are now valid forever.
p.s.: Built with AI help.