From 6f31627406a63d09c3ec33494a54158095663111 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Aug 2014 12:42:22 +0100 Subject: [PATCH] Also create decryption certs if there is no config file. --- src/lib/config.cc | 16 ++++++++++++---- src/lib/config.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/config.cc b/src/lib/config.cc index 576b02fdc..d20536f14 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -95,6 +95,8 @@ Config::read () if (!boost::filesystem::exists (file (false))) { /* Make a new set of signing certificates and key */ _signer.reset (new dcp::Signer (openssl_path ())); + /* And decryption keys */ + make_decryption_keys (); return; } @@ -238,13 +240,19 @@ Config::read () if (!f.optional_string_child ("DecryptionCertificate") || !f.optional_string_child ("DecryptionPrivateKey")) { /* Generate our own decryption certificate and key if either is not present in config */ - boost::filesystem::path p = dcp::make_certificate_chain (openssl_path ()); - _decryption_certificate = dcp::Certificate (dcp::file_to_string (p / "leaf.signed.pem")); - _decryption_private_key = dcp::file_to_string (p / "leaf.key"); - boost::filesystem::remove_all (p); + make_decryption_keys (); } } +void +Config::make_decryption_keys () +{ + boost::filesystem::path p = dcp::make_certificate_chain (openssl_path ()); + _decryption_certificate = dcp::Certificate (dcp::file_to_string (p / "leaf.signed.pem")); + _decryption_private_key = dcp::file_to_string (p / "leaf.key"); + boost::filesystem::remove_all (p); +} + /** @return Filename to write configuration to */ boost::filesystem::path Config::file (bool old) const diff --git a/src/lib/config.h b/src/lib/config.h index 310d3c6f5..3cfaa1200 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -426,6 +426,7 @@ private: boost::filesystem::path file (bool) const; void read (); void write () const; + void make_decryption_keys (); /** number of threads to use for J2K encoding on the local machine */ int _num_local_encoding_threads; -- 2.30.2