@@ -38,9 +38,11 @@ class SignedDocument < REXML::Document
3838 DSIG = "http://www.w3.org/2000/09/xmldsig#"
3939
4040 attr_accessor :signed_element_id
41+ attr_accessor :errors
4142
42- def initialize ( response )
43+ def initialize ( response , errors = [ ] )
4344 super ( response )
45+ @errors = errors
4446 extract_signed_element_id
4547 end
4648
@@ -62,6 +64,7 @@ def validate_document(idp_cert_fingerprint, soft = true)
6264 fingerprint = Digest ::SHA1 . hexdigest ( cert . to_der )
6365
6466 if fingerprint != idp_cert_fingerprint . gsub ( /[^a-zA-Z0-9]/ , "" ) . downcase
67+ @errors << "Fingerprint mismatch"
6568 return soft ? false : ( raise OneLogin ::RubySaml ::ValidationError . new ( "Fingerprint mismatch" ) )
6669 end
6770
@@ -108,6 +111,7 @@ def validate_signature(base64_cert, soft = true)
108111 digest_value = Base64 . decode64 ( REXML ::XPath . first ( ref , "//ds:DigestValue" , { "ds" => DSIG } ) . text )
109112
110113 unless digests_match? ( hash , digest_value )
114+ @errors << "Digest mismatch"
111115 return soft ? false : ( raise OneLogin ::RubySaml ::ValidationError . new ( "Digest mismatch" ) )
112116 end
113117 end
@@ -123,6 +127,7 @@ def validate_signature(base64_cert, soft = true)
123127 signature_algorithm = algorithm ( REXML ::XPath . first ( signed_info_element , "//ds:SignatureMethod" , { "ds" => DSIG } ) )
124128
125129 unless cert . public_key . verify ( signature_algorithm . new , signature , canon_string )
130+ @errors << "Key validation error"
126131 return soft ? false : ( raise OneLogin ::RubySaml ::ValidationError . new ( "Key validation error" ) )
127132 end
128133
0 commit comments