summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@oath.com>2018-09-10 11:54:51 +0000
committerHåvard Pettersen <havardpe@oath.com>2018-09-10 11:54:51 +0000
commitc34734cd3a36290a5a9fedfea5c650dff5307a12 (patch)
tree52bf0565bbc951388d0b764291ebb61b62ca4a92 /vespalib
parent0a003477115303a75f8f5b68e71815e4943b04c7 (diff)
enable tls when VESPA_TLS_CONFIG_FILE is set
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/net/crypto_engine.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/vespalib/src/vespa/vespalib/net/crypto_engine.cpp b/vespalib/src/vespa/vespalib/net/crypto_engine.cpp
index 8832b4b1cfe..38a91456cba 100644
--- a/vespalib/src/vespa/vespalib/net/crypto_engine.cpp
+++ b/vespalib/src/vespa/vespalib/net/crypto_engine.cpp
@@ -5,6 +5,10 @@
#include <chrono>
#include <thread>
#include <vespa/vespalib/xxhash/xxhash.h>
+#include <vespa/vespalib/stllike/string.h>
+#include <vespa/vespalib/net/tls/transport_security_options.h>
+#include <vespa/vespalib/net/tls/transport_security_options_reading.h>
+#include <vespa/vespalib/net/tls/tls_crypto_engine.h>
#include <assert.h>
namespace vespalib {
@@ -156,9 +160,13 @@ public:
};
CryptoEngine::SP create_default_crypto_engine() {
- // TODO: check VESPA_TLS_CONFIG_FILE here
- // return std::make_shared<XorCryptoEngine>();
- return std::make_shared<NullCryptoEngine>();
+ const char *env = getenv("VESPA_TLS_CONFIG_FILE");
+ vespalib::string cfg_file = env ? env : "";
+ if (cfg_file.empty()) {
+ return std::make_shared<NullCryptoEngine>();
+ }
+ auto tls_opts = net::tls::read_options_from_json_file(cfg_file);
+ return std::make_shared<TlsCryptoEngine>(*tls_opts);
}
} // namespace vespalib::<unnamed>