From 7e9330aec0500328c9f50b21015949ef0094095a Mon Sep 17 00:00:00 2001 From: Rohith Date: Thu, 30 Jun 2016 14:07:00 +0100 Subject: [PATCH] - fixing up the format of the bundle - shifting the version to v0.1.0 --- CHANGELOG.md | 8 ++++++++ formats.go | 27 +++++++++++++++++++++------ main.go | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 227ba9a..b6dc5a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +#### **Version v0.1.0** + +##### FEATURES + +BUGS + * Fixed the bundle format to produce four file, a bundle with cert+ca, and the FILENAME-ca.pem, FILENAME-key.pem, + and the FILENAME.pem certificate + #### **Version v0.0.9-1** ##### FEATURES diff --git a/formats.go b/formats.go index ee172bc..a45e120 100644 --- a/formats.go +++ b/formats.go @@ -90,18 +90,33 @@ func writeCertificateFile(filename string, data map[string]interface{}) error { } func writeCertificateBundleFile(filename string, data map[string]interface{}) error { - certificateFile := fmt.Sprintf("%s.crt", filename) - caFile := fmt.Sprintf("%s.ca", filename) - certificate := fmt.Sprintf("%s\n\n%s", data["certificate"], data["private_key"]) - ca := fmt.Sprintf("%s", data["issuing_ca"]) + bundleFile := fmt.Sprintf("%s-bundle.pem", filename) + keyFile := fmt.Sprintf("%s-key.pem", filename) + caFile := fmt.Sprintf("%s-ca.pem", filename) + certFile := fmt.Sprintf("%s.pem", filename) - if err := writeFile(certificateFile, []byte(certificate)); err != nil { + bundle := fmt.Sprintf("%s\n\n%s", data["certificate"], data["issuing_ca"]) + key := fmt.Sprintf("%s\n", data["private_key"]) + ca := fmt.Sprintf("%s\n", data["issuing_ca"]) + certificate := fmt.Sprintf("%s\n", data["certificate"]) + + if err := writeFile(bundleFile, []byte(bundle)); err != nil { glog.Errorf("failed to write the bundled certificate file, error: %s", err) return err } + if err := writeFile(certFile, []byte(certificate)); err != nil { + glog.Errorf("failed to write the certificate file, errro: %s", err) + return err + } + if err := writeFile(caFile, []byte(ca)); err != nil { - glog.Errorf("failed to write the ca certificate file, errro: %s", err) + glog.Errorf("failed to write the ca file, errro: %s", err) + return err + } + + if err := writeFile(keyFile, []byte(key)); err != nil { + glog.Errorf("failed to write the key file, errro: %s", err) return err } diff --git a/main.go b/main.go index 718a55b..be8868b 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ import ( const ( Prog = "vault-sidekick" - Version = "v0.0.9-2" + Version = "v0.1.0" ) func main() {