lib/sepa/utilities.rb
def validate_signature(doc, certificate, canonicalization_method)
      node = doc.at('xmlns|SignedInfo', xmlns: DSIG)

      return false unless node

      node = case canonicalization_method
             when :normal
               node.canonicalize
             when :exclusive
               canonicalize_exclusively node
             end

      signature = doc.at('xmlns|SignatureValue', xmlns: DSIG).content
      signature = decode(signature)

      # Return true or false
      certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)
    end
# Verifies that a signature has been created with the private key of a certificate
#
# @param doc [Nokogiri::XML::Document] the document that contains the signature
# @param certificate [OpenSSL::X509::Certificate] the certificate to verify the signature
#   against
# @param canonicalization_method [Symbol] The canonicalization method that has been used to
#   canonicalize the SignedInfo node. Accepts `:normal` or `:exclusive`.
# @return [true] if signature verifies
# @return [false] if signature fails to verify or if it cannot be found
Verifies that a signature has been created with the private key of a certificate
Verifies that a signature has been created with the private key of a certificate
def validate_signature(doc, certificate, canonicalization_method)
      node = doc.at('xmlns|SignedInfo', xmlns: DSIG)
      return false unless node
      node = case canonicalization_method
             when :normal
               node.canonicalize
             when :exclusive
               canonicalize_exclusively node
             end
      signature = doc.at('xmlns|SignatureValue', xmlns: DSIG).content
      signature = decode(signature)
      certificate.public_key.verify(OpenSSL::Digest::SHA1.new, signature, node)
    end
def validate_signature ( doc , certificate , canonicalization_method ) node = doc . at ( 'xmlns|SignedInfo' , xmlns : DSIG ) return false unless node node = case canonicalization_method when :normal node . canonicalize when :exclusive canonicalize_exclusively node end signature = doc . at ( 'xmlns|SignatureValue' , xmlns : DSIG ) . content signature = decode ( signature ) certificate . public_key . verify ( OpenSSL :: Digest :: SHA1 . new , signature , node ) end
Verifies that a signature has been created with the private key of a certificate
Verifies that a signature has been created with the private key of a certificate
# Return true or false
if signature verifies
if signature verifies
true
if signature fails to verify or if it cannot be found
if signature fails to verify or if it cannot be found
false
doc
the document that contains the signature
the document that contains the signature
certificate
the certificate to verify the signature against
the certificate to verify the signature against
canonicalization_method
The canonicalization method that has been used to canonicalize the SignedInfo node. Accepts `:normal` or `:exclusive`.
The canonicalization method that has been used to canonicalize the SignedInfo node . Accepts ` : normal ` or ` : exclusive ` .