Introduction
This article provides guidance on diagnosing and resolving OIDC authentication failures between Jenkins CI and JFrog Artifactory. Specifically, it addresses the 400 Bad Signature error that frequently occurs when Jenkins users attempt to exchange OIDC tokens for Artifactory access tokens after a Jenkins configuration reload via the Configuration as Code (JCasC) plugin.
Symptoms
Users are unable to exchange Jenkins OIDC tokens for Artifactory access tokens, resulting in a 400 Bad Signature error. This issue typically surfaces immediately after the Jenkins instance reloads its configuration via the Jenkins Configuration as Code (JCasC) plugin, causing CI/CD pipeline builds to fail.
Root Cause
This issue is caused by a conflict between how the Jenkins OIDC Provider plugin rotates its cryptographic keys and how Artifactory caches them.
-
Jenkins Key Generation: When Jenkins reloads via JCasC, the OIDC Provider plugin generates a new public/private key pair. However, the plugin ties the Key ID (kid) directly to a static credential ID. As a result, the newly generated key pair uses the exact same kid as the previous key pair.
-
Artifactory Caching Logic: To minimize network overhead, Artifactory caches the entire JSON Web Key Set (JWKS) retrieved from the OIDC provider. Per the OIDC specification, Artifactory only returns to the provider's jwks_uri to refresh its cache when an incoming token presents an unrecognized kid.
-
The Conflict: Because the new Jenkins token arrives with a kid that Artifactory already has cached, Artifactory attempts to verify the new token using the old, cached public key. The cryptographic signature fails, resulting in the 400 Bad Signature error.
Solutions and Workarounds
There are multiple ways to address this behavior, depending on your operational requirements.
Option 1: Programmatic Cache Flush (Recommended Workaround)
You can force Artifactory to update its JWKS cache without restarting nodes by sending an intentional dummy request that triggers Artifactory's cache refresh logic.
Configure your Jenkins instance to execute a dummy OIDC token exchange request immediately following a JCasC reload, injecting a randomized or unrecognized kid (e.g., kid="force-cache-flush-1").
-
Mechanism: Artifactory will receive the unfamiliar kid, realize its cache may be outdated, and automatically fetch the latest JWKS payload from Jenkins. This payload will contain the new public key stored under the standard static kid.
-
Result: While the dummy request will fail, the cache is instantly repopulated. All subsequent, legitimate pipeline requests will succeed.
Option 2: Lower the JWKS Cache TTL (Mitigation)
If implementing a programmatic flush is not feasible, you can lower the Time-To-Live (TTL) of the JWKS cache so Artifactory naturally clears the invalid key much faster, reducing pipeline downtime.
-
Navigate to your Artifactory Access configuration directory: /opt/jfrog/artifactory/var/etc/access/
-
Create a backup of access.config.latest.yml
-
Add the following to the access.config.latest.yml file to lower the cache expiration from the default 24 hours (86400 seconds) to 5 minutes (300 seconds):
security:
oidc:
jwks:
cache:
expire-after-write-seconds: 300-
Save the file. Artifactory will automatically detect it, apply the settings on the fly, and rename the file to access.config.import.yml.
-
Restart for the changes to take effect.
Option 3: Node Restart (Immediate Manual Fix)
Because the JWKS cache is maintained in-memory on a per-node basis, restarting the affected Artifactory node(s) will clear the cache. Upon startup, Artifactory will fetch the latest keys on the next authentication request. This is highly disruptive but effective for isolated incidents.
Option 4: Jenkins Plugin Update (Long-Term Resolution)
To permanently resolve the root cause, the Jenkins OIDC Provider plugin must be updated to align with OIDC specifications. The plugin must be modified to generate a unique kid alongside every new key pair generated during a JCasC reload, rather than tying the kid to a static credential ID. The related GitHub issue can be found here.