3030require "digest/sha1"
3131require "digest/sha2"
3232require "onelogin/ruby-saml/validation_error"
33+ require "onelogin/ruby-saml/utils"
3334
3435module XMLSecurity
3536
@@ -48,7 +49,7 @@ def validate_document(idp_cert_fingerprint, soft = true)
4849 # get cert from response
4950 cert_element = REXML ::XPath . first ( self , "//ds:X509Certificate" , { "ds" => DSIG } )
5051 raise OneLogin ::RubySaml ::ValidationError . new ( "Certificate element missing in response (ds:X509Certificate)" ) unless cert_element
51- base64_cert = cert_element . text
52+ base64_cert = OneLogin :: RubySaml :: Utils . element_text ( cert_element )
5253 cert_text = Base64 . decode64 ( base64_cert )
5354 cert = OpenSSL ::X509 ::Certificate . new ( cert_text )
5455
@@ -99,14 +100,14 @@ def validate_signature(base64_cert, soft = true)
99100 digest_algorithm = algorithm ( REXML ::XPath . first ( ref , "//ds:DigestMethod" , 'ds' => DSIG ) )
100101
101102 hash = digest_algorithm . digest ( canon_hashed_element )
102- digest_value = Base64 . decode64 ( REXML ::XPath . first ( ref , "//ds:DigestValue" , { "ds" => DSIG } ) . text )
103+ digest_value = Base64 . decode64 ( OneLogin :: RubySaml :: Utils . element_text ( REXML ::XPath . first ( ref , "//ds:DigestValue" , { "ds" => DSIG } ) ) )
103104
104105 unless digests_match? ( hash , digest_value )
105106 return soft ? false : ( raise OneLogin ::RubySaml ::ValidationError . new ( "Digest mismatch" ) )
106107 end
107108 end
108109
109- base64_signature = REXML ::XPath . first ( @sig_element , "//ds:SignatureValue" , { "ds" => DSIG } ) . text
110+ base64_signature = OneLogin :: RubySaml :: Utils . element_text ( REXML ::XPath . first ( @sig_element , "//ds:SignatureValue" , { "ds" => DSIG } ) )
110111 signature = Base64 . decode64 ( base64_signature )
111112
112113 # get certificate object
0 commit comments