-
-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow SP certificates to be OpenSSL::X509::Certificate #726
base: v2.x
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -373,28 +373,33 @@ def get_all_sp_certs | |
|
||
# Validate certificate, certificate_new, private_key, and sp_cert_multi params. | ||
def validate_sp_certs_params! | ||
multi = sp_cert_multi && !sp_cert_multi.empty? | ||
cert = certificate && !certificate.empty? | ||
cert_new = certificate_new && !certificate_new.empty? | ||
pk = private_key && !private_key.empty? | ||
if multi && (cert || cert_new || pk) | ||
has_multi = sp_cert_multi && !sp_cert_multi.empty? | ||
has_pk = private_key && !private_key.empty? | ||
if has_multi && (cert?(certificate) || cert?(certificate_new) || has_pk) | ||
raise ArgumentError.new("Cannot specify both sp_cert_multi and certificate, certificate_new, private_key parameters") | ||
end | ||
end | ||
|
||
# Check if a certificate is present. | ||
def cert?(cert) | ||
return true if cert.is_a?(OpenSSL::X509::Certificate) | ||
|
||
cert && !cert.empty? | ||
end | ||
|
||
# Get certs from certificate, certificate_new, and private_key parameters. | ||
def get_sp_certs_single | ||
certs = { :signing => [], :encryption => [] } | ||
|
||
sp_key = RubySaml::Utils.build_private_key_object(private_key) | ||
cert = RubySaml::Utils.build_cert_object(certificate) | ||
cert = build_cert_object(certificate) | ||
if cert || sp_key | ||
ary = [cert, sp_key].freeze | ||
certs[:signing] << ary | ||
certs[:encryption] << ary | ||
end | ||
|
||
cert_new = RubySaml::Utils.build_cert_object(certificate_new) | ||
cert_new = build_cert_object(certificate_new) | ||
if cert_new | ||
ary = [cert_new, sp_key].freeze | ||
certs[:signing] << ary | ||
|
@@ -429,7 +434,7 @@ def get_sp_certs_multi | |
end | ||
|
||
certs[type] << [ | ||
RubySaml::Utils.build_cert_object(cert), | ||
build_cert_object(cert), | ||
RubySaml::Utils.build_private_key_object(key) | ||
].freeze | ||
end | ||
|
@@ -438,5 +443,11 @@ def get_sp_certs_multi | |
certs.each { |_, ary| ary.freeze } | ||
certs | ||
end | ||
|
||
def build_cert_object(cert) | ||
return cert if cert.is_a?(OpenSSL::X509::Certificate) | ||
|
||
OneLogin::RubySaml::Utils.build_cert_object(cert) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's just change this method in OneLogin::RubySaml::Utils to return a cert if one is given as an argument (it should be "idempotent") Same with RubySaml::Utils.build_private_key_object There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 Your code, your decision 😄 Will change that. |
||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all changes in this file can be rolled back
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it we get the initial NoMethodError again (because
validate_sp_certs_params
is called beforeUtils.build_cert_object
):There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I will check this later, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what status is this?