From: Carl Hetherington Date: Thu, 24 Jan 2019 17:34:37 +0000 (+0000) Subject: Slightly hacky but hopefully functional fix for KDMs after the changes X-Git-Tag: v1.6.2~6 X-Git-Url: https://main.carlh.net/gitweb/?p=libdcp.git;a=commitdiff_plain;h=2d05cab0e47ef437c3e5fa0f574f1eb4b1cfd64a Slightly hacky but hopefully functional fix for KDMs after the changes to signer. The KDM stuff uses add_signature_value() but not sign() since it has to allow pass-through of a KDM (so it handles etc. itself). This means we have to make the indentation-adding optional. It might have been nicer to make indent() not add indentation if it's not already there. --- diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index 353444fa..61414436 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -603,7 +603,7 @@ CertificateChain::sign (xmlpp::Element* parent, Standard standard) const signature->add_child("SignatureValue", "dsig"); signature->add_child("KeyInfo", "dsig"); - add_signature_value (signature, "dsig"); + add_signature_value (signature, "dsig", true); } @@ -613,7 +613,7 @@ CertificateChain::sign (xmlpp::Element* parent, Standard standard) const * @param ns Namespace to use for the signature XML nodes. */ void -CertificateChain::add_signature_value (xmlpp::Element* parent, string ns) const +CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool add_indentation) const { cxml::Node cp (parent); xmlpp::Node* key_info = cp.node_child("KeyInfo")->node (); @@ -644,7 +644,9 @@ CertificateChain::add_signature_value (xmlpp::Element* parent, string ns) const throw runtime_error ("could not read private key"); } - indent (parent, 2); + if (add_indentation) { + indent (parent, 2); + } int const r = xmlSecDSigCtxSign (signature_context, parent->cobj ()); if (r < 0) { throw MiscError (String::compose ("could not sign (%1)", r)); diff --git a/src/certificate_chain.h b/src/certificate_chain.h index 8b54604d..63ef8901 100644 --- a/src/certificate_chain.h +++ b/src/certificate_chain.h @@ -103,7 +103,7 @@ public: bool private_key_valid () const; void sign (xmlpp::Element* parent, Standard standard) const; - void add_signature_value (xmlpp::Element* parent, std::string ns) const; + void add_signature_value (xmlpp::Element* parent, std::string ns, bool add_indentation) const; boost::optional key () const { return _key; diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index 9d581451..996708ad 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -554,6 +554,7 @@ public: xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ()); } + indent (document->get_root_node(), 0); return document; } @@ -670,7 +671,7 @@ EncryptedKDM::EncryptedKDM ( xmlpp::Node::NodeList children = doc->get_root_node()->get_children (); for (xmlpp::Node::NodeList::const_iterator i = children.begin(); i != children.end(); ++i) { if ((*i)->get_name() == "Signature") { - signer->add_signature_value (dynamic_cast(*i), "ds"); + signer->add_signature_value (dynamic_cast(*i), "ds", false); } }