From: Carl Hetherington Date: Sat, 6 Jan 2018 23:27:45 +0000 (+0000) Subject: Check that we can decrypt a DKDM when it is loaded (#1011). X-Git-Tag: v2.11.38~3 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=f2991b10f26dd8996cfcdcbc2128f7e9db36f634 Check that we can decrypt a DKDM when it is loaded (#1011). --- diff --git a/ChangeLog b/ChangeLog index c0e5b3468..809cf7096 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-01-06 Carl Hetherington + * Check that we can decrypt a DKDM when it is loaded into + the KDM creator (#1011). + * Fix crash in some cases when an incorrect KDM has been added to a DCP (#1000). diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 26e7f8479..9995d80a9 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -406,9 +406,20 @@ private: if (d->ShowModal() == wxID_OK) { shared_ptr new_dkdm; try { - new_dkdm.reset ( - new DKDM (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE))) - ); + dcp::EncryptedKDM ekdm(dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)); + + /* Decrypt the DKDM to make sure that we can */ + shared_ptr chain = Config::instance()->decryption_chain(); + DCPOMATIC_ASSERT (chain->key()); + dcp::DecryptedKDM dkdm(ekdm, chain->key().get()); + + new_dkdm.reset(new DKDM(ekdm)); + shared_ptr group = dynamic_pointer_cast (selected_dkdm ()); + if (!group) { + group = Config::instance()->dkdms (); + } + add_dkdm_model (new_dkdm, group); + add_dkdm_view (new_dkdm); } catch (dcp::KDMFormatError& e) { error_dialog ( this, @@ -418,14 +429,12 @@ private: ) ); return; + } catch (dcp::KDMDecryptionError) { + error_dialog ( + this, + _("Could not decrypt the DKDM. Perhaps it was not created with the correct certificate.") + ); } - - shared_ptr group = dynamic_pointer_cast (selected_dkdm ()); - if (!group) { - group = Config::instance()->dkdms (); - } - add_dkdm_model (new_dkdm, group); - add_dkdm_view (new_dkdm); } d->Destroy (); }