-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces KMS functionality. Given an encrypted private key for the cert authority the signing daemon will call out to KMS on startup to decrypt the key and load it into the ssh-agent. Docs were updated accordingly.
- Loading branch information
Showing
5 changed files
with
172 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"github.com/aws/aws-sdk-go/aws" | ||
"github.com/aws/aws-sdk-go/aws/ec2metadata" | ||
"github.com/aws/aws-sdk-go/aws/session" | ||
"github.com/aws/aws-sdk-go/service/kms" | ||
"github.com/codegangsta/cli" | ||
"io/ioutil" | ||
"os" | ||
) | ||
|
||
func encryptFlags() []cli.Flag { | ||
return []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "key-id", | ||
Value: "", | ||
Usage: "The ARN of the KMS key to use", | ||
}, | ||
cli.StringFlag{ | ||
Name: "output", | ||
Value: "ca-key.kms", | ||
Usage: "The filename for key output", | ||
}, | ||
} | ||
} | ||
|
||
func encryptKey(c *cli.Context) { | ||
region, err := ec2metadata.New(session.New(), aws.NewConfig()).Region() | ||
if err != nil { | ||
fmt.Printf("Unable to determine our region: %s", err) | ||
os.Exit(1) | ||
} | ||
keyContents, err := ioutil.ReadAll(bufio.NewReader(os.Stdin)) | ||
if err != nil { | ||
fmt.Printf("Unable to read private key: %s", err) | ||
os.Exit(1) | ||
} | ||
svc := kms.New(session.New(), aws.NewConfig().WithRegion(region)) | ||
params := &kms.EncryptInput{ | ||
Plaintext: keyContents, | ||
KeyId: aws.String(c.String("key-id")), | ||
} | ||
resp, err := svc.Encrypt(params) | ||
if err != nil { | ||
fmt.Printf("Unable to Encrypt CA key: %v\n", err) | ||
os.Exit(1) | ||
} | ||
keyContents = resp.CiphertextBlob | ||
ioutil.WriteFile(c.String("output"), resp.CiphertextBlob, 0444) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters