diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-29 00:07:10 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-02-11 22:26:38 +0100 |
| commit | e18630852de1ac02c23c74cbe7643845b6f4bd17 (patch) | |
| tree | 9860c35db04509b5edf818d4ad6667b0c59651de /src/tools | |
| parent | 6ca8f63ff524330bf58877ffe963466495e46758 (diff) | |
Cleanup: extract encrypt() call from Film::make_kdm().
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic.cc | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index deaa15afd..1923a12a3 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -944,34 +944,30 @@ private: dcp::LocalTime to (Config::instance()->signer_chain()->leaf().not_after()); to.add_days (-1); - optional<dcp::EncryptedKDM> kdm; - try { - kdm = _film->make_kdm ( - Config::instance()->decryption_chain()->leaf(), - vector<string>(), - dialog.cpl(), - from, to, - dcp::Formulation::MODIFIED_TRANSITIONAL_1, - true, - 0 - ); - } catch (dcp::NotEncryptedError& e) { - error_dialog (this, _("CPL's content is not encrypted.")); - } catch (exception& e) { - error_dialog (this, e.what ()); - } catch (...) { - error_dialog (this, _("An unknown exception occurred.")); + auto signer = Config::instance()->signer_chain(); + if (!signer->valid()) { + error_dialog(this, _("The certificate chain for signing is invalid")); + return; } - if (kdm) { + optional<dcp::EncryptedKDM> kdm; + try { + auto const decrypted_kdm = _film->make_kdm(dialog.cpl(), from, to); + auto const kdm = decrypted_kdm.encrypt(signer, Config::instance()->decryption_chain()->leaf(), {}, dcp::Formulation::MODIFIED_TRANSITIONAL_1, true, 0); if (dialog.internal()) { auto dkdms = Config::instance()->dkdms(); - dkdms->add (make_shared<DKDM>(kdm.get())); + dkdms->add(make_shared<DKDM>(kdm)); Config::instance()->changed (); } else { auto path = dialog.directory() / (_film->dcp_name(false) + "_DKDM.xml"); - kdm->as_xml (path); + kdm.as_xml(path); } + } catch (dcp::NotEncryptedError& e) { + error_dialog (this, _("CPL's content is not encrypted.")); + } catch (exception& e) { + error_dialog (this, e.what ()); + } catch (...) { + error_dialog (this, _("An unknown exception occurred.")); } } |
