Class: XmlSigner::Signer
- Inherits:
-
Object
- Object
- XmlSigner::Signer
- Defined in:
- lib/xml_signer/xml_signer.rb
Instance Method Summary collapse
-
#initialize(pfx_file, pfx_password) ⇒ Signer
constructor
A new instance of Signer.
- #sign(xml_string) ⇒ Object
Constructor Details
#initialize(pfx_file, pfx_password) ⇒ Signer
Returns a new instance of Signer.
8 9 10 11 12 13 14 |
# File 'lib/xml_signer/xml_signer.rb', line 8 def initialize(pfx_file, pfx_password) @pfx_file = pfx_file @pfx_password = pfx_password @p12 = OpenSSL::PKCS12.new(File.read(@pfx_file), @pfx_password) @cert = @p12.certificate @key = @p12.key end |
Instance Method Details
#sign(xml_string) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/xml_signer/xml_signer.rb', line 16 def sign(xml_string) doc = Nokogiri::XML(xml_string) signature = generate_signature_element(doc) doc.root.add_child(signature) doc.to_xml end |