RemoveAllKeys removes from the agent all the keys matching the given options.
(opts ...AgentOption)
| 222 | |
| 223 | // RemoveAllKeys removes from the agent all the keys matching the given options. |
| 224 | func (a *Agent) RemoveAllKeys(opts ...AgentOption) (bool, error) { |
| 225 | o := newOptions(opts) |
| 226 | keys, err := a.List() |
| 227 | if err != nil { |
| 228 | return false, errors.Wrap(err, "error listing keys") |
| 229 | } |
| 230 | |
| 231 | var removed bool |
| 232 | for _, key := range keys { |
| 233 | if o.filterBySignatureKey == nil || o.filterBySignatureKey(key) { |
| 234 | if err := a.Remove(key); err != nil { |
| 235 | return false, errors.Wrap(err, "error removing key") |
| 236 | } |
| 237 | removed = true |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | return removed, nil |
| 242 | } |
| 243 | |
| 244 | // AddCertificate adds the given certificate to the agent. |
| 245 | func (a *Agent) AddCertificate(subject string, cert *ssh.Certificate, priv interface{}) error { |
no test coverage detected