From 41f82b24a39914bf71d799b4960048989a4b3f82 Mon Sep 17 00:00:00 2001 From: Don Goodman-Wilson Date: Mon, 9 Apr 2018 16:14:40 +0200 Subject: [PATCH] For compatibility with Now, base64-encode the RSA keys in env vars https://github.com/zeit/now-cli/issues/749 --- conanfile.txt | 1 + configuration.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/conanfile.txt b/conanfile.txt index 37b0595..273a8a0 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -23,6 +23,7 @@ cpp-jwt/[~=1.0]@DEGoodmanWilson/stable libsodium/[~=1.0]@bincrafters/stable cpr/[~=1.3]@DEGoodmanWilson/stable inja/[~=1.0]@DEGoodmanWilson/stable +base64/[~=1.0]@DEGoodmanWilson/stable # for testing Catch/[~=1.9]@bincrafters/stable diff --git a/configuration.cpp b/configuration.cpp index 377fd04..e5c3f6a 100644 --- a/configuration.cpp +++ b/configuration.cpp @@ -21,6 +21,8 @@ #include #include +#include + std::string read_from_file_(const std::string &path) { @@ -88,8 +90,8 @@ std::string getenvstr_(const std::string &key) configuration::configuration() : mongo_uri{getenvstr_("MONGO_URI")}, mailgun_api_key{getenvstr_("MAILGUN_API_KEY")}, - public_key{getenv("PUBLIC_KEY")}, - private_key{getenv("PRIVATE_KEY")} + public_key{base64_decode(getenv("PUBLIC_KEY"))}, + private_key{base64_decode(getenv("PRIVATE_KEY"))} { if (mongo_uri.empty()) {