Skip to content
Snippets Groups Projects
Commit 0a4a2ba0 authored by sid77's avatar sid77 Committed by Marco Bonetti
Browse files

Add private key along certificate

parent 870e7b84
No related branches found
Tags v1.20140508-1
No related merge requests found
...@@ -40,8 +40,8 @@ func TestLoadCert(t *testing.T) { ...@@ -40,8 +40,8 @@ func TestLoadCert(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Error reading from agent: %v", err) t.Fatalf("Error reading from agent: %v", err)
} }
if len(listedKeys) != 1 { if len(listedKeys) != 2 {
t.Fatalf("Expected 1 key, got %d", len(listedKeys)) t.Fatalf("Expected 2 keys, got %d", len(listedKeys))
} }
if !bytes.Equal(listedKeys[0].Marshal(), c.Marshal()) { if !bytes.Equal(listedKeys[0].Marshal(), c.Marshal()) {
t.Fatal("Certs not equal") t.Fatal("Certs not equal")
......
...@@ -42,6 +42,14 @@ func installCert(a agent.Agent, cert *ssh.Certificate, key key) error { ...@@ -42,6 +42,14 @@ func installCert(a agent.Agent, cert *ssh.Certificate, key key) error {
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)
} }
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 return nil
} }
...@@ -147,5 +155,5 @@ func main() { ...@@ -147,5 +155,5 @@ func main() {
if err := installCert(a, cert, priv); err != nil { if err := installCert(a, cert, priv); err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
fmt.Println("Certificate added.") fmt.Println("Credentials added.")
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment