-
Notifications
You must be signed in to change notification settings - Fork 147
✨ Inject Ironic CA Cert in IPA #851
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
base: main
Are you sure you want to change the base?
Changes from all 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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -54,6 +54,7 @@ deploy_logs_local_path = /shared/log/ironic/deploy | |||||||||||||
| # See https://bugzilla.redhat.com/show_bug.cgi?id=1822763 | ||||||||||||||
| max_command_attempts = 30 | ||||||||||||||
| certificates_path = {{ env.IRONIC_GEN_CERT_DIR }} | ||||||||||||||
| api_ca_file = {{ env.IPA_CACERT_FILE }} | ||||||||||||||
|
Comment on lines
56
to
+57
|
||||||||||||||
| certificates_path = {{ env.IRONIC_GEN_CERT_DIR }} | |
| api_ca_file = {{ env.IPA_CACERT_FILE }} | |
| certificates_path = {{ env.IRONIC_GEN_CERT_DIR }} | |
| {% if env.IPA_CACERT_FILE %} | |
| api_ca_file = {{ env.IPA_CACERT_FILE }} | |
| {% endif %} |
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.
to me an empty file would denote a configuration issue (default bundle path not correctly set) and thus I'm not sure we want to make it conditional here, but I'm not opposed to do so if you see other benefits to it.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| cpio | ||
| dnsmasq | ||
| dosfstools | ||
| httpd | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ export IRONIC_SSL_PROTOCOL=${IRONIC_SSL_PROTOCOL:-"-ALL +TLSv1.2 +TLSv1.3"} | |||||||||||||
| export IPXE_SSL_PROTOCOL=${IPXE_SSL_PROTOCOL:-"-ALL +TLSv1.2 +TLSv1.3"} | ||||||||||||||
| export IRONIC_VMEDIA_SSL_PROTOCOL=${IRONIC_VMEDIA_SSL_PROTOCOL:-"ALL"} | ||||||||||||||
|
|
||||||||||||||
| export DEFAULT_CACERT_BUNDLE=${DEFAULT_CACERT_BUNDLE:-"/etc/ssl/cert.pem"} | ||||||||||||||
|
|
||||||||||||||
| # Node image storage is using the same cert and port as the API | ||||||||||||||
| export IRONIC_CERT_FILE=/certs/ironic/tls.crt | ||||||||||||||
| export IRONIC_KEY_FILE=/certs/ironic/tls.key | ||||||||||||||
|
|
@@ -22,7 +24,8 @@ export RESTART_CONTAINER_CERTIFICATE_UPDATED=${RESTART_CONTAINER_CERTIFICATE_UPD | |||||||||||||
| export MARIADB_CACERT_FILE=/certs/ca/mariadb/tls.crt | ||||||||||||||
| export BMC_CACERTS_PATH=/certs/ca/bmc | ||||||||||||||
| export BMC_CACERT_FILE=/conf/bmc-tls.pem | ||||||||||||||
| export IRONIC_CACERT_FILE=/certs/ca/ironic/tls.crt | ||||||||||||||
| export IRONIC_CACERT_FILE=${IRONIC_CACERT_FILE:-"/certs/ca/ironic/tls.crt"} | ||||||||||||||
| export IPA_CACERT_FILE=/conf/ipa-tls.pem | ||||||||||||||
|
|
||||||||||||||
| export IPXE_TLS_PORT="${IPXE_TLS_PORT:-8084}" | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -129,3 +132,42 @@ if ls "${BMC_CACERTS_PATH}"/* > /dev/null 2>&1; then | |||||||||||||
| else | ||||||||||||||
| export BMC_TLS_ENABLED="false" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| if [[ -f "${WEBSERVER_CACERT_FILE:-}" ]]; then | ||||||||||||||
| copy_atomic "${WEBSERVER_CACERT_FILE}" "${IPA_CACERT_FILE}" | ||||||||||||||
| elif [[ -f "${DEFAULT_CACERT_BUNDLE}" ]]; then | ||||||||||||||
|
Member
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. I cannot make up my mind about this aspect (hence my somewhat erratic comments below). While unlikely, some folks may have CA certificates built into their IPA images (in fact, I know people who do that, albeit outside of Metal3 context). This change will start overriding them with a generic bundle from CentOS Stream. I'm leaning towards preferring an opt-in approach, even if it involves setting |
||||||||||||||
| copy_atomic "${DEFAULT_CACERT_BUNDLE}" "${IPA_CACERT_FILE}" | ||||||||||||||
| fi | ||||||||||||||
|
Member
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. There is no else here...
Contributor
Author
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. would a be okay for you, or should I find another way ?
Member
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. I'm not sure about making a CA bundle required on the Ironic side. Someone may have it embedded in the ramdisk. In fact, this is most certainly going to break OpenShift because we don't provide IRONIC_CACERT_FILE.
Member
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. So yeah, the way the code is written now, it's better to fail explicitly. Otherwise, IPA_CACERT_FILE may not exist at all or may contain only the Ironic CA. |
||||||||||||||
|
|
||||||||||||||
| if [[ -f "${IRONIC_CACERT_FILE}" ]]; then | ||||||||||||||
| cat "${IRONIC_CACERT_FILE}" >> "${IPA_CACERT_FILE}" | ||||||||||||||
diconico07 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| if ! openssl verify -CAfile "${IPA_CACERT_FILE}" "${IRONIC_CERT_FILE}" > /dev/null 2>&1; then | ||||||||||||||
| # if we are unable to verify the Ironic cert file set IPA_INSECURE to true | ||||||||||||||
|
Member
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 issue a warning message here |
||||||||||||||
| export IRONIC_IPA_INSECURE="1" | ||||||||||||||
|
Member
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. ...which leads to IPA being insecure, fine...
Member
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. Ah, okay, so OpenShift should fall back here. |
||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| generate_cacert_bundle_initrd() | ||||||||||||||
| ( | ||||||||||||||
| set -euo pipefail | ||||||||||||||
|
|
||||||||||||||
| local output_path="$1" | ||||||||||||||
| local temp_dir | ||||||||||||||
|
|
||||||||||||||
| temp_dir="$(mktemp -d)" | ||||||||||||||
| trap 'rm -rf "${temp_dir}"' EXIT | ||||||||||||||
|
|
||||||||||||||
| chmod 0755 "${temp_dir}" | ||||||||||||||
|
|
||||||||||||||
| cd "${temp_dir}" | ||||||||||||||
|
|
||||||||||||||
| mkdir -p etc/ironic-python-agent.d etc/ironic-python-agent | ||||||||||||||
|
||||||||||||||
| mkdir -p etc/ironic-python-agent.d etc/ironic-python-agent | |
| mkdir -p etc/ironic-python-agent.d etc/ironic-python-agent | |
| if [ ! -f "${IPA_CACERT_FILE}" ]; then | |
| echo "ERROR: IPA CA certificate bundle '${IPA_CACERT_FILE}' not found; cannot generate initrd bundle." >&2 | |
| return 1 | |
| fi |
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.
...then we end up here copying non-existent files, and doing bad configs....
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.
...and eventually we end up here doing reboot loop?