Skip to content

Conversation

@adamlazik1
Copy link
Contributor

No description provided.

@adamlazik1
Copy link
Contributor Author

Only drafting stage.

@adamlazik1
Copy link
Contributor Author

I will keep this in draft because there will be four PRs in total that should get merged at roughly the same time, but I do believe that this is now ready for review.

Comment on lines 16 to 17
rescue
Rails.logger.info("Unable to fetch CA public key. Using public key authentication instead.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the proxy doesn't have the ca_pubkey endpoint, the get will raise and we'll get this warning. If the proxy has that endpoint, but doesn't have a ca_pubkey configured, the get will silently return an empty string, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Looking at it now I don't know why I made it like this, the message makes little sense. I updated it to reflect the behavior of the pubkey api call.

@adamlazik1 adamlazik1 marked this pull request as ready for review July 11, 2025 06:55
@adamlazik1
Copy link
Contributor Author

Switching back to draft since the feature got postponed to 3.16

@adamlazik1 adamlazik1 marked this pull request as draft July 21, 2025 09:05
@adamlazik1 adamlazik1 force-pushed the ssh-cert-support branch 2 times, most recently from b757ba9 to 620dc78 Compare December 18, 2025 14:35
@lhellebr
Copy link
Contributor

/packit build

@packit-as-a-service
Copy link

Account lhellebr has no write access nor is author of PR!

@adamlazik1
Copy link
Contributor Author

/packit build

1 similar comment
@adamlazik1
Copy link
Contributor Author

/packit build

Copy link
Contributor

@adamruzicka adamruzicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The N-2 support needs to be handled, otherwise lgtm

def ca_pubkey
get('ca_pubkey')&.strip
rescue => e
raise ProxyException.new(url, e, N_('Unable to fetch CA public key'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be problematic. We should support running with N-2 proxies, which may not have the ca_pubkey endpoint at all. Either we could treat 404s as not an error or have different behaviour based on the version of the proxy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would returning nil instead of throwing exception suffice? Rest of the application logic treats nil as unset CA pubkey and proceeds with the standard pubkey.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not using a catch-all like this to prevent masking real issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @lhellebr change of behavior: if capsule does not have the ca_pubkey endpoint due to older version, nil ca_pubkey is returned instead of erroring out.

def ca_pubkey
get('ca_pubkey')&.strip
rescue RestClient::ResourceNotFound => e
Foreman::Logging.exception("Unable to fetch CA public key", e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick:
On my dev setup, this generates roughly 110 lines in the logs which is a bit excessive for a non-error case. I'd be fine with this being silent or just logging a single line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces SSH Certificate Authority (CA) support for Foreman Remote Execution, allowing SSH proxies to use CA-signed certificates for authentication instead of individual public keys.

  • Adds database column and API support for storing CA public keys on SmartProxy models
  • Implements logic to use CA keys when available and exclude regular SSH keys from proxies with CA configured
  • Extends host parameters to include SSH CA keys alongside regular SSH keys with proper merging from both proxies and host-level parameters

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
db/migrate/20250606125543_add_ca_pub_key_to_smart_proxy.rb Adds ca_pubkey column to smart_proxies table
app/views/api/v2/smart_proxies/ca_pubkey.json.rabl Exposes CA public key via API as remote_execution_ca_pubkey
lib/foreman_remote_execution/plugin.rb Registers the new CA pubkey RABL template extension
app/lib/proxy_api/remote_execution_ssh.rb Implements ca_pubkey API method to fetch CA public key from smart proxy
app/models/concerns/foreman_remote_execution/smart_proxy_extensions.rb Adds ca_pubkey getter and update_ca_pubkey method to SmartProxy model
app/models/concerns/foreman_remote_execution/host_extensions.rb Adds remote_execution_ssh_ca_keys method and modifies key handling to exclude regular keys when CA is configured
test/unit/concerns/host_extensions_test.rb Adds comprehensive test coverage for SSH CA key functionality including parameter merging and proxy behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamlazik1
Copy link
Contributor Author

Updated based on copilot feedback.

@adamruzicka adamruzicka merged commit f01bdb3 into theforeman:master Jan 6, 2026
17 checks passed
@adamruzicka
Copy link
Contributor

Thank you @adamlazik1 !

@adamlazik1 adamlazik1 deleted the ssh-cert-support branch January 6, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants