+2018-07-07 Carl Hetherington <cth@carlh.net>
+
+ * Give better errors when incorrect KDMs are used (#1326).
+
2018-07-06 Carl Hetherington <cth@carlh.net>
* Add option to enable/disable KDM forensic marking.
/*
- Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2018 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
#include "dcp_content.h"
#include <dcp/dcp.h>
#include <dcp/decrypted_kdm.h>
+#include <dcp/exceptions.h>
#include <boost/foreach.hpp>
+#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 */
if (_dcp_content->kdm ()) {
BOOST_FOREACH (shared_ptr<dcp::DCP> 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<const dcp::CertificateChain> 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());
+ }
+ }
}
}
CURLcode const r = curl_easy_perform (curl);
if (r != CURLE_OK) {
- throw KDMError (String::compose (_("Failed to send email (%1)"), curl_easy_strerror (r)));
+ throw KDMError (_("Failed to send email"), curl_easy_strerror (r));
}
curl_slist_free_all (recipients);
KDMAsContentError::KDMAsContentError ()
: runtime_error (_("This file is a KDM. KDMs should be added to DCP content by right-clicking the content and choosing \"Add KDM\"."))
-{}
+{
+
+}
+
+KDMError::KDMError (string s, string d)
+ : runtime_error (String::compose ("%1 (%2)", s, d))
+ , _summary (s)
+ , _detail (d)
+{
+
+}
class KDMError : public std::runtime_error
{
public:
- explicit KDMError (std::string s)
- : std::runtime_error (s)
- {}
+ KDMError (std::string s, std::string d);
+
+ std::string summary () const {
+ return _summary;
+ }
+
+ std::string detail () const {
+ return _detail;
+ }
+
+private:
+ std::string _summary;
+ std::string _detail;
};
/** @class PixelFormatError
set_progress (1);
set_state (FINISHED_ERROR);
+ } catch (KDMError& e) {
+
+ set_error (e.summary(), e.detail());
+ set_progress (1);
+ set_state (FINISHED_ERROR);
+
} catch (std::exception& e) {
set_error (
#include "lib/dcp_examiner.h"
#include "lib/ffmpeg_content.h"
#include "lib/audio_content.h"
+#include "lib/config.h"
#include <dcp/cpl.h>
#include <dcp/exceptions.h>
#include <wx/wx.h>
/* The DCP is probably missing */
} catch (dcp::KDMDecryptionError) {
/* We have an incorrect KDM */
+ } catch (KDMError) {
+ /* We have an incorrect KDM */
}
} else {
_kdm->Enable (false);
try {
dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
} catch (exception& e) {
- error_dialog (_parent, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what()));
+ error_dialog (_parent, _("Could not load KDM"), std_to_wx(e.what()));
d->Destroy ();
return;
}