Commit 0a4a2ba0 authored by sid77's avatar sid77 Committed by Marco Bonetti

Add private key along certificate

parent 870e7b84
......@@ -40,8 +40,8 @@ func TestLoadCert(t *testing.T) {
if err != nil {
t.Fatalf("Error reading from agent: %v", err)
}
if len(listedKeys) != 1 {
t.Fatalf("Expected 1 key, got %d", len(listedKeys))
if len(listedKeys) != 2 {
t.Fatalf("Expected 2 keys, got %d", len(listedKeys))
}
if !bytes.Equal(listedKeys[0].Marshal(), c.Marshal()) {
t.Fatal("Certs not equal")
......
......@@ -42,6 +42,14 @@ func installCert(a agent.Agent, cert *ssh.Certificate, key key) error {
if err := a.Add(pubcert); err != nil {
return fmt.Errorf("error importing certificate: %s", err)
}
privkey := agent.AddedKey{
PrivateKey: key,
Comment: cert.KeyId,
LifetimeSecs: uint32(lifetime),
}
if err := a.Add(privkey); err != nil {
return fmt.Errorf("error importing key: %s", err)
}
return nil
}
......@@ -147,5 +155,5 @@ func main() {
if err := installCert(a, cert, priv); err != nil {
log.Fatalln(err)
}
fmt.Println("Certificate added.")
fmt.Println("Credentials added.")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment