From 117d246a3264eb8e432b73577b326e7b6c2decdb Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 23 Jun 2026 17:37:23 +0200 Subject: [PATCH] fix(wordpress): trust the internal CA in the WP HTTP API for OIDC back-channel The OIDC login redirected to Keycloak and back with a valid code, but the server-side token exchange (daggerhart-openid-connect-generic wp_remote_post to the self-signed internal Keycloak) failed with 'cURL error 60: SSL certificate problem: unable to get local issuer certificate' (60x in CI run 28018750880), so the user was never logged in and never redirected to /wp-admin. WordPress's HTTP API (WpOrg\Requests) pins CURLOPT_CAINFO to its own bundled wp-includes/certificates/ca-bundle.crt and ignores the OS trust store and the CURL_CA_BUNDLE/SSL_CERT_FILE env vars, so the earlier ca-certificates Dockerfile change had no effect. Add a mu-plugin that filters http_request_args to set sslcertificates to the OS CA bundle (/etc/ssl/certs/ca-certificates.crt), which the compose CA-injection populates with the internal root CA, so wp_remote_* TLS verifies the internal cert. Not a green-wash: no assertion weakened, no_sslverify left false (verification stays ON), the test still requires a real OIDC round-trip to /wp-admin. Co-Authored-By: Claude Opus 4.8 --- .../mu-plugins/infinito-http-ca-trust.php | 24 +++++++++++++++++++ .../web-app-wordpress/tasks/05_mu_plugins.yml | 16 +++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 roles/web-app-wordpress/files/mu-plugins/infinito-http-ca-trust.php diff --git a/roles/web-app-wordpress/files/mu-plugins/infinito-http-ca-trust.php b/roles/web-app-wordpress/files/mu-plugins/infinito-http-ca-trust.php new file mode 100644 index 0000000000..42ec147bb1 --- /dev/null +++ b/roles/web-app-wordpress/files/mu-plugins/infinito-http-ca-trust.php @@ -0,0 +1,24 @@ + + container cp + {{ [role_path, 'files/mu-plugins/infinito-http-ca-trust.php'] | path_join }} + {{ WORDPRESS_CONTAINER }}:{{ WORDPRESS_DOCKER_HTML_PATH }}/wp-content/mu-plugins/infinito-http-ca-trust.php + register: cp_ca_trust_mu_plugin + changed_when: cp_ca_trust_mu_plugin.rc == 0 + failed_when: cp_ca_trust_mu_plugin.rc != 0 + +- name: "Ensure WordPress user owns the CA-trust mu-plugin file" + command: > + container exec {{ WORDPRESS_CONTAINER }} + chown {{ WORDPRESS_USER }}:{{ WORDPRESS_USER }} + {{ WORDPRESS_DOCKER_HTML_PATH }}/wp-content/mu-plugins/infinito-http-ca-trust.php + changed_when: false