File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,7 +47,13 @@ def initialize(response)
4747 def validate_document ( idp_cert_fingerprint , soft = true )
4848 # get cert from response
4949 cert_element = REXML ::XPath . first ( self , "//ds:X509Certificate" , { "ds" => DSIG } )
50- raise OneLogin ::RubySaml ::ValidationError . new ( "Certificate element missing in response (ds:X509Certificate)" ) unless cert_element
50+ unless cert_element
51+ if soft
52+ return false
53+ else
54+ raise OneLogin ::RubySaml ::ValidationError . new ( "Certificate element missing in response (ds:X509Certificate)" )
55+ end
56+ end
5157 base64_cert = cert_element . text
5258 cert_text = Base64 . decode64 ( base64_cert )
5359 cert = OpenSSL ::X509 ::Certificate . new ( cert_text )
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ class XmlSecurityTest < Test::Unit::TestCase
2626 end
2727 end
2828
29+ should "not raise an error when softly validating the document and the X509Certificate is missing" do
30+ response = Base64 . decode64 ( response_document )
31+ response . sub! ( /<ds:X509Certificate>.*<\/ ds:X509Certificate>/ , "" )
32+ document = XMLSecurity ::SignedDocument . new ( response )
33+ assert_nothing_raised do
34+ assert !document . validate_document ( "a fingerprint" , true ) # The fingerprint isn't relevant to this test
35+ end
36+ end
37+
2938 should "should raise Fingerprint mismatch" do
3039 exception = assert_raise ( OneLogin ::RubySaml ::ValidationError ) do
3140 @document . validate_document ( "no:fi:ng:er:pr:in:t" , false )
You can’t perform that action at this time.
0 commit comments