diff options
author | sid77 <sid77@slackware.it> | 2016-08-15 21:24:06 +0100 |
---|---|---|
committer | Marco Bonetti <marco@intercom.io> | 2016-08-16 09:46:46 +0100 |
commit | 0a4a2ba0fceeae85847bbe95370eb3e7aaf1b99b (patch) | |
tree | 1ade1e68cb7463eb87b3dd14911436e727b1ea63 | |
parent | 870e7b848f3c3a8e2846bc377b575466c66bd0ca (diff) |
Add private key along certificate
-rw-r--r-- | cmd/cashier/client_test.go | 4 | ||||
-rw-r--r-- | cmd/cashier/main.go | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/cmd/cashier/client_test.go b/cmd/cashier/client_test.go index f0176c6..b82d78f 100644 --- a/cmd/cashier/client_test.go +++ b/cmd/cashier/client_test.go @@ -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") diff --git a/cmd/cashier/main.go b/cmd/cashier/main.go index a9c509f..047c13e 100644 --- a/cmd/cashier/main.go +++ b/cmd/cashier/main.go @@ -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.") } |