Skip to content

Commit

Permalink
Add a bundle file and some newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Shannon Wynter authored and Shannon Wynter committed Mar 2, 2017
1 parent dc71499 commit dc5404e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func main() {
certFile := flag.String("certFile", "", "Output certificate file")
keyFile := flag.String("keyFile", "", "Output key file")
caFile := flag.String("caFile", "", "Output ca file")
bundleFile := flag.String("bundleFile", "", "Ouput a ca+cert bundle")
command := flag.String("cmd", "", "Command to execute")
showVersion := flag.Bool("version", false, "Show version and exit")

Expand Down Expand Up @@ -159,15 +160,20 @@ func main() {
if err != nil {
log.WithError(err).Fatal("Unable to get keys")
}
if err := ioutil.WriteFile(*certFile, []byte(pkiSecret.Data["certificate"].(string)), 0640); err != nil {
if err := ioutil.WriteFile(*certFile, []byte(pkiSecret.Data["certificate"].(string)+"\n"), 0640); err != nil {
log.WithError(err).WithField("file", *certFile).Fatal("Failed to write certificate")
}
if err := ioutil.WriteFile(*caFile, []byte(pkiSecret.Data["issuing_ca"].(string)), 0640); err != nil {
if err := ioutil.WriteFile(*caFile, []byte(pkiSecret.Data["issuing_ca"].(string)+"\n"), 0640); err != nil {
log.WithError(err).WithField("file", *caFile).Fatal("Failed to write ca")
}
if err := ioutil.WriteFile(*keyFile, []byte(pkiSecret.Data["private_key"].(string)), 0640); err != nil {
if err := ioutil.WriteFile(*keyFile, []byte(pkiSecret.Data["private_key"].(string)+"\n"), 0640); err != nil {
log.WithError(err).WithField("file", *keyFile).Fatal("Failed to write key")
}
if *bundleFile != "" {
if err := ioutil.WriteFile(*bundleFile, []byte(pkiSecret.Data["certificate"].(string)+"\n"+pkiSecret.Data["issuing_ca"].(string)+"\n"), 0640); err != nil {
log.WithError(err).WithField("file", *certFile).Fatal("Failed to write certificate")
}
}

certRenewalInterval = renewDuration(pkiSecret.LeaseDuration)

Expand Down

0 comments on commit dc5404e

Please sign in to comment.