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 <Signature> 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.
signature->add_child("SignatureValue", "dsig");
signature->add_child("KeyInfo", "dsig");
signature->add_child("SignatureValue", "dsig");
signature->add_child("KeyInfo", "dsig");
- add_signature_value (signature, "dsig");
+ add_signature_value (signature, "dsig", true);
* @param ns Namespace to use for the signature XML nodes.
*/
void
* @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 ();
{
cxml::Node cp (parent);
xmlpp::Node* key_info = cp.node_child("KeyInfo")->node ();
throw runtime_error ("could not read private key");
}
throw runtime_error ("could not read private key");
}
+ 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));
int const r = xmlSecDSigCtxSign (signature_context, parent->cobj ());
if (r < 0) {
throw MiscError (String::compose ("could not sign (%1)", r));
bool private_key_valid () const;
void sign (xmlpp::Element* parent, Standard standard) const;
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<std::string> key () const {
return _key;
boost::optional<std::string> key () const {
return _key;
xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ());
}
xmlAddID (0, document->cobj(), (const xmlChar *) i->first.c_str(), i->second->cobj ());
}
+ indent (document->get_root_node(), 0);
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") {
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<xmlpp::Element*>(*i), "ds");
+ signer->add_signature_value (dynamic_cast<xmlpp::Element*>(*i), "ds", false);