Skip to content

Commit

Permalink
Use settings.idp_cert_fingerprint_algorithm in idp_metadata_parser fo…
Browse files Browse the repository at this point in the history
…r fingerprint instead of SHA1
  • Loading branch information
Dmitry Stolyarov committed Jan 15, 2016
1 parent 18fb134 commit 2ff9d8e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/onelogin/ruby-saml/idp_metadata_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def parse(idp_metadata, options = {})
settings.idp_slo_target_binding ||= single_logout_service_binding(settings.idp_slo_target_parse_binding_priority)
settings.idp_slo_target_url = single_logout_service_url(settings.idp_slo_target_binding)
settings.idp_cert = certificate_base64
settings.idp_cert_fingerprint = fingerprint
settings.idp_cert_fingerprint = fingerprint(settings.idp_cert_fingerprint_algorithm)
end
end

Expand Down Expand Up @@ -198,11 +198,13 @@ def certificate

# @return [String|nil] the SHA-1 fingerpint of the X509Certificate if it exists
#
def fingerprint
def fingerprint(fingerprint_algorithm)
@fingerprint ||= begin
if certificate
cert = OpenSSL::X509::Certificate.new(certificate)
Digest::SHA1.hexdigest(cert.to_der).upcase.scan(/../).join(":")

fingerprint_alg = XMLSecurity::BaseDocument.new.algorithm(fingerprint_algorithm).new
fingerprint_alg.hexdigest(cert.to_der).upcase.scan(/../).join(":")
end
end
end
Expand Down

0 comments on commit 2ff9d8e

Please sign in to comment.