-
Notifications
You must be signed in to change notification settings - Fork 991
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
Fixes #31049 - Introduce server CA file setting #8076
Fixes #31049 - Introduce server CA file setting #8076
Conversation
Issues: #31049 |
Do we have installer PR for this? |
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.
I'm concerned that this would break registration via Smart Proxies. Should we introduce a different macro for that?
I think @ekohl is right about breaking the through proxy registration. However with this new setting, the macro should load certificates from both files. That way, we'd make sure the user can use whatever method if they deploy certificates provided by this macro. The other option is to go with what is proposed here and introduce a second macro to provide the same for proxies and then pick whichever is needed in the template. However the added value of this imho doesn't outbalance the effort. I'd lean towards the existing macro providing certs from both files. |
Not needed here, but I also thought about introducing something like |
should it be served by the application or rather just apache from /public? Anyway that's not in scope for this PR. Next steps I think are
@kamils-iRonin please let me know if there are any questions from your side, thanks! |
@ares @ekohl we could introduce def foreman_server_ca_cert(server_ca_file_enabled: true, ssl_ca_file_enabled: true)
if server_ca_file_enabled && File.exist?(Setting[:server_ca_file])
File.read(Setting[:server_ca_file])
elsif ssl_ca_file_enabled && File.exist?(Setting[:ssl_ca_file])
File.read(Setting[:ssl_ca_file])
else
msg = N_("SSL CA file not found, check the 'Server CA file' in Settings > Authentication")
raise Foreman::Exception.new(msg)
end
end |
From the signature I would expect it concat both when both are true but the implementation only returns one. I think curl is happy to have both CA bundles together and use whatever validates it. |
c2286ea
to
c767580
Compare
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.
Mostly some readability suggestions. Overall I think it looks good but let me know if you want to apply the suggestions.
c767580
to
82673da
Compare
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.
LGTM. @ares want to have a look at latest iteration?
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.
I'm sorry it took me a while to get back to this. I have one little ask about error handling, otherwise I tested and it works well indeed. Ready to merge after that comments is resolved.
setting_values << Setting[:ssl_ca_file] if ssl_ca_file_enabled | ||
files_content = setting_values.compact.map do |setting_value| | ||
File.read(setting_value) | ||
rescue Errno::ENOENT, Errno::EACCES |
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.
We should rescue the File.read for more exceptions, if I specify wrong path (e.g. a directory) it's not catched by this.
I'd recommend wrapping the File.read
in begin end block and just rescue
instead of trying to list all Errno::* here. Also I'd say we should log something in case of such error, currently we silently ignore this and admin has no way to find out the set file is not accessible. This would deserve a warning in a log I think.
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.
I've added logger and rescue from StandardError
Also reiterating a question around the installer PR that ondrej asked. This settings work out of the box so it's not strictly necessary, but I wonder if we should preconfigure this setting from the installer and if someone started working on that already or we need to look into it. |
82673da
to
e49bad1
Compare
I've opened a first draft here: theforeman/puppet-foreman#910 |
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.
Small nits, otherwise it looks OK to me.
1a5f6a5
to
614efad
Compare
my appologies, this now requires a rebase, I think the installer PR is ready so this can get in once rebased |
614efad
to
7f1e777
Compare
7f1e777
to
de46ba0
Compare
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.
CI fails with:
NameError: undefined local variable or method `error' for #<Class:0x000000000e8e98e8>
/home/jenkins/workspace/test_develop_pr_core/database/postgresql/ruby/2.5/slave/fast/test/unit/foreman/renderer/renderers_shared_tests.rb:274:in `block (2 levels) in <module:RenderersSharedTests>'
I'm not sure if it's related, but would you mind taking a look?
[test foreman][test upgrade] |
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.
Just trying to push this forward, I think I found the cause of test failures.
Setting[:server_ca_file] = cert_path | ||
Setting[:ssl_ca_file] = 'not-existing-file' | ||
|
||
assert_raise Foreman::Exception do |
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.
This could be bit more specific by adding assertion for the message
assert_raise Foreman::Exception do | |
assert_raise Foreman::Exception, '<expected message>' do |
assert_raise Foreman::Exception do | ||
subject | ||
end | ||
end | ||
end | ||
|
||
assert_includes error.message, '[Foreman::Exception]: No such file or directory' |
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.
This seems to be quite forgotten and I belive that makes the tests to fail.
de46ba0
to
0a023b8
Compare
@ares tests seems to be 🍏 now ^_^ |
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.
Works for me 👍 Thanks @kamils-iRonin
Thanks @kamils-iRonin and @ezr-ondrej for taking care of the merge. |
Note to self: we can introduce some URL to expose this. It would replace Katello's |
No description provided.