X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdcp.cc;h=28e5c4fd28a0b4da3b9012f50552dd20b8cc49cb;hb=2c35515c5db7b8e49c17fd4ddfa085393d544f9d;hp=7e6c66c6c2d4f93e288cae1f41b10d40379c4723;hpb=bd2fe66dca73364485471725b8b5bc65b9b835cd;p=dcpomatic.git diff --git a/src/lib/dcp.cc b/src/lib/dcp.cc index 7e6c66c6c..28e5c4fd2 100644 --- a/src/lib/dcp.cc +++ b/src/lib/dcp.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2016 Carl Hetherington + Copyright (C) 2014-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -23,9 +23,13 @@ #include "dcp_content.h" #include #include +#include #include +#include "i18n.h" + using std::list; +using std::string; using boost::shared_ptr; /** Find all the CPLs in our directories, cross-add assets and return the CPLs */ @@ -54,7 +58,24 @@ DCP::cpls () const if (_dcp_content->kdm ()) { BOOST_FOREACH (shared_ptr i, dcps) { - i->add (dcp::DecryptedKDM (_dcp_content->kdm().get(), Config::instance()->decryption_chain()->key().get ())); + try { + i->add (dcp::DecryptedKDM (_dcp_content->kdm().get(), Config::instance()->decryption_chain()->key().get ())); + } catch (dcp::KDMDecryptionError& e) { + /* Flesh out the error a bit */ + string const kdm_subject_name = _dcp_content->kdm()->recipient_x509_subject_name(); + bool on_chain = false; + shared_ptr dc = Config::instance()->decryption_chain(); + BOOST_FOREACH (dcp::Certificate i, dc->root_to_leaf()) { + if (i.subject() == kdm_subject_name) { + on_chain = true; + } + } + if (!on_chain) { + throw KDMError (_("KDM was not made for DCP-o-matic's decryption certificate."), e.what()); + } else if (on_chain && kdm_subject_name != dc->leaf().subject()) { + throw KDMError (_("KDM was made for DCP-o-matic but not for its leaf certificate."), e.what()); + } + } } }