signer
signer copied to clipboard
Removing namespaces and elements
Hi!
Thanks for this gem. I'm using it to sign some XML files here, but our local government has some custom and strict rules for the documents. I'm using this code:
signer = Signer.new(data)
signer.cert = OpenSSL::X509::Certificate.new(File.read(files[:cert]))
signer.private_key = OpenSSL::PKey::RSA.new(File.read(files[:key]), File.read(files[:pwd]).chomp)
signer.security_node = signer.document.root
signer.security_token_id = ""
signer.digest!(signer.document.root, :id => "id", :enveloped => true)
signer.sign!(:issuer_serial => true)
signer.to_xml
And I'd like to check if is possible to:
-
Remove namespaces. I need
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id"
be removed from the main element. They just want their custom namespace. -
Remove some elements. To conform to their XSD, I need to remove the elements
<X509SubjectName>, <X509IssuerSerial>, <KeyValue>, <RSAKeyValue>, <Modulus> and <Exponent>
. -
Change reference URI. To conform to their XSD, I need to replace the "#id" on
Reference URI="#id"
to a custom one. -
Insert new elements. I need to insert
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
before `</Transforms>' ends. -
Remove new lines. They won't allow a new line after
<?xml version="1.0"?>
, I need the signed result to don't use newline character. I could remove on the result, but seems the sign would be invalid if it was there when signing.
Thanks!