Skip to content
Snippets Groups Projects
Commit 420dae7d authored by Niall Sheridan's avatar Niall Sheridan Committed by GitHub
Browse files

Merge pull request #26 from sid77/master

Load private key in memory as well
parents 870e7b84 0a4a2ba0
No related branches found
No related tags found
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