Skip to content

Commit

Permalink
Merge pull request #555 from appbot/multi-cert-validation-error
Browse files Browse the repository at this point in the history
Define 'soft' variable to prevent exception when doc cert is invalid
  • Loading branch information
pitbulk authored Nov 9, 2020
2 parents 24e90a3 + d0e117a commit 5322d19
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/xml_security.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def validate_document(idp_cert_fingerprint, soft = true, options = {})
validate_signature(base64_cert, soft)
end

def validate_document_with_cert(idp_cert)
def validate_document_with_cert(idp_cert, soft = true)
# get cert from response
cert_element = REXML::XPath.first(
self,
Expand Down
13 changes: 13 additions & 0 deletions test/xml_security_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,19 @@ class XmlSecurityTest < Minitest::Test
end

describe '#validate_document_with_cert' do
describe 'with invalid document ' do
describe 'when certificate is invalid' do
let(:document_data) { read_response('response_with_signed_message_and_assertion.xml')
.sub(/<ds:X509Certificate>.*<\/ds:X509Certificate>/, "<ds:X509Certificate>invalid<\/ds:X509Certificate>") }
let(:document) { OneLogin::RubySaml::Response.new(document_data).document }
let(:idp_cert) { OpenSSL::X509::Certificate.new(ruby_saml_cert_text) }

it 'is invalid' do
refute document.validate_document_with_cert(idp_cert), 'Document should be invalid'
end
end
end

describe 'with valid document ' do
describe 'when response has cert' do
let(:document_data) { read_response('response_with_signed_message_and_assertion.xml') }
Expand Down

0 comments on commit 5322d19

Please sign in to comment.