File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -260,9 +260,11 @@ def validate_document_with_cert(idp_cert)
260260 # check saml response cert matches provided idp cert
261261 if idp_cert . to_pem != cert . to_pem
262262 return false
263+ end
264+ else
265+ base64_cert = Base64 . encode64 ( idp_cert . to_pem )
263266 end
264- validate_signature ( base64_cert , true )
265- end
267+ validate_signature ( base64_cert , true )
266268 end
267269
268270 def validate_signature ( base64_cert , soft = true )
Original file line number Diff line number Diff line change @@ -393,5 +393,29 @@ class XmlSecurityTest < Minitest::Test
393393 end
394394 end
395395 end
396+
397+ describe '#validate_document_with_cert' do
398+ describe 'with valid document ' do
399+ describe 'when response has cert' do
400+ let ( :document_data ) { read_response ( 'response_with_signed_message_and_assertion.xml' ) }
401+ let ( :document ) { OneLogin ::RubySaml ::Response . new ( document_data ) . document }
402+ let ( :idp_cert ) { OpenSSL ::X509 ::Certificate . new ( ruby_saml_cert_text ) }
403+ let ( :fingerprint ) { '4b68c453c7d994aad9025c99d5efcf566287fe8d' }
404+
405+ it 'is valid' do
406+ assert document . validate_document_with_cert ( idp_cert ) , 'Document should be valid'
407+ end
408+ end
409+
410+ describe 'when response has no cert but you have local cert' do
411+ let ( :document ) { OneLogin ::RubySaml ::Response . new ( response_document_valid_signed_without_x509certificate ) . document }
412+ let ( :idp_cert ) { OpenSSL ::X509 ::Certificate . new ( ruby_saml_cert_text ) }
413+
414+ it 'is valid' do
415+ assert document . validate_document_with_cert ( idp_cert ) , 'Document should be valid'
416+ end
417+ end
418+ end
419+ end
396420 end
397421end
You can’t perform that action at this time.
0 commit comments