diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c3c1c22..319753b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,38 +1,57 @@ # Changelog -## [Unreleased] +## [0.9.0] - 2026-11-24 + +### Breaking changes + +* **JWT audiences:** Empty expected-audience sets could succeed in 0.8.17. All `JwtSvid.parseAndValidate` and `parseInsecure` overloads now throw `IllegalArgumentException`; supply the audience the application expects (#431). +* **Watch retries:** `CANCELLED`, `UNAUTHENTICATED`, `UNIMPLEMENTED` and `FAILED_PRECONDITION` now terminate watches instead of retrying, stopping automatic reconnection and further rotations. Handle termination and restore the watch after resolving the cause. `INVALID_ARGUMENT` was already terminal; initial `PERMISSION_DENIED` still retries with backoff. + +### Upgrade considerations + +* **Helper truststores:** Before the first 0.9.0 update, move manually installed certificates that must be retained outside the `.` alias pattern. Matching certificates can be deleted even if the Helper did not create them. This risk is separate from stale-authority cleanup (#492). +* **TLS peers:** Previously accepted peer certificates can now fail verification, including with `SpiffeIdVerifier.acceptAny()`. Ensure peers meet the X.509-SVID profile and chain to trusted authorities; custom verifiers now run only after chain validation (#510, #511). +* **Helper failures:** `KeyStoreHelper.run(true)` fails on the first watcher error, including `PERMISSION_DENIED` after startup. The CLI closes its client and exits 1, ending retries; resolve the cause and restart the Helper. Initial `PERMISSION_DENIED` before any update still retries with backoff under the default policy (#488, #491). +* **Native transports:** Upgrade separately pinned `grpc-netty-*` artifacts with core. Custom shaded JARs must preserve `META-INF/services/io.spiffe.workloadapi.internal.GrpcChannelProvider`; supplied platform-specific fat JARs already include it (#108, #523). +* **Recovery:** Direct `WorkloadApiClient.watch*` callers can register a new watch after resolving a terminal failure. Built-in sources log the failure and can keep serving cached material after rotations stop; recreate the source and switch its consumers to resume rotations. Closing the old source closes its client, so use a fresh client for the replacement. Permission denial does not automatically invalidate built-in source caches. ### Added -* Add `X509Bundle.marshal()` and `JwtBundle.marshal()` to serialize bundles as PEM certificates and as a JWKS document, the formats read by `parse` -* Publish a `java-spiffe-bom` Bill of Materials to align the versions of the java-spiffe modules. -* Add `X509Svid.marshalCertificates()` and `X509Svid.marshalPrivateKey()` to serialize an X.509-SVID as PEM certificates and a PEM PKCS#8 private key, the formats read by `parse` and `load`, and `marshalRawCertificates()` and `marshalRawPrivateKey()` for the ASN.1 DER formats read by `parseRaw` (#515) -* Add a `spiffeIdVerifier` option to `SpiffeSslContextFactory.SslContextOptions`, so an `SSLContext` can verify peer SPIFFE IDs with a custom `SpiffeIdVerifier` instead of a fixed set of accepted SPIFFE IDs -* Add `SpiffeIdVerifier.acceptAny()`, `acceptId()`, `acceptOneOf()` and `acceptMemberOf()` factory methods for verifiers that accept any SPIFFE ID, a specific SPIFFE ID, one of a set of SPIFFE IDs, or any SPIFFE ID in a trust domain +* Add PEM/JWKS bundle serialization and PEM/DER X.509-SVID serialization (#515). +* Publish `java-spiffe-bom` to align library and transport versions. +* Add `SslContextOptions.spiffeIdVerifier` and `SpiffeIdVerifier.acceptAny()`, `acceptId()`, `acceptOneOf()` and `acceptMemberOf()` factories. +* Add `ClientOptions.retryExecutorService` and `RetryHandler.tryScheduleRetry(Runnable)`, retaining `void scheduleRetry(Runnable)`. Clients close supplied retry executors (#79). ### Changed -* Retry Workload API `PERMISSION_DENIED` responses with backoff. With the default client and no initialization timeout, `DefaultX509Source.newSource()`, `DefaultJwtSource.newSource()` and `CachedJwtSource.newSource()` now wait indefinitely for an unregistered workload instead of failing immediately. Set a nonzero `initTimeout` or the `spiffe.newX509Source.timeout` / `spiffe.newJwtSource.timeout` system property to bound the wait. +* Report post-update `PERMISSION_DENIED` immediately, suppress repeated withdrawal notifications until recovery, and report terminal failures when retries cannot continue (#491). +* Consistently report `X509BundleException` for X.509 bundle watches and wrap invalid trust-domain keys in watch-specific exceptions with their causes preserved. Adjust handlers relying on earlier exception types (#491). +* `DefaultWorkloadApiClient.newClient`, `DefaultX509Source.newSource`, `DefaultJwtSource.newSource` and `CachedJwtSource.newSource` no longer write automatically created clients, executors or defaults into supplied options. Getters may remain `null`; reusing options creates independent default clients and executors. Explicitly configure and retain resources to inspect or share them. `KeyStoreHelper.create` still fills in `keyStoreType`, `keyAlias` and `workloadApiClient` on its options; reusing those options shares the client, which Helper `close()` shuts down (#497). ### Fixed -* Always report terminal Workload API watch failures after a permission denial, including repeated denials, preserving the exception type and cause. -* Replace the Helper's complete trust bundle set with one TrustStore write per update, remove authorities for absent trust domains, and preserve the live store when preparing a replacement fails. Only certificate aliases of the form `.` are Helper-managed (#492) -* Reject X.509-SVID leaf certificates with a root SPIFFE ID path in `X509SvidValidator.verifyChain`, which `SpiffeTrustManager` uses for peer certificates (#510) -* Ignore JWKs with an unsupported key type when parsing a JWT bundle instead of rejecting the whole bundle, per the SPIFFE bundle spec (#512) -* Serialize `java-spiffe-helper` KeyStore and TrustStore files to memory before writing them, so a store or encoding failure no longer leaves an empty or partial file (#490) -* Stage every `java-spiffe-helper` KeyStore and TrustStore update in a copy and adopt it in memory only after the file write succeeds, so a failed private key or authority update is no longer persisted by a later write, and an entry that cannot be serialized no longer makes every later write fail (#490) -* Stop splitting the `io.spiffe.workloadapi.internal` package between `java-spiffe-core` and the `grpc-netty-*` modules, which broke builds on the Java module path. Each `grpc-netty-*` module now registers a channel provider in its own package that core loads with `ServiceLoader`, picking the one for the current OS and architecture (#108). Upgrade `java-spiffe-core` and the `grpc-netty-*` artifact together, since an older `grpc-netty-*` jar still contains the shared package - -### Build - -* Check core and provider binary compatibility against the latest stable Maven Central release. -* Bump `io.netty:netty-transport-native-kqueue` to 4.2.17.Final to match the Netty version used by gRPC, and fail `check` when the macOS transport modules drift from it. +* Enforce X.509-SVID peer leaf requirements for URI SANs, non-root SPIFFE ID paths, CA flags and key usages. Extract SPIFFE IDs only from URI SANs (#510, #511). +* Validate certificate chains before invoking `SpiffeIdVerifier`; invalid chains no longer reach the callback. +* Validate and normalize trust-domain names using ASCII rules independently of the JVM locale (#496). +* Reject watches on closed clients with `IllegalStateException`. +* Propagate asynchronous source initialization errors; preserve watches after rejected post-initialization updates so later rotations can apply (#486). +* Propagate Helper watch failures through `run`, giving CLI failures exit status 1 (#488). +* Safely publish JWT bundle updates across threads; refresh cached JWT-SVIDs without `iat`, and return `null` from `getIssuedAt()` when absent (#429). +* Preserve sub-second retry delays and report failed retry scheduling. +* Accept bracketed IPv6 Workload API addresses; ignore unsupported JWK types while retaining supported bundle authorities (#512). +* Preserve all current Helper bundle authorities and remove stale indexes and absent trust domains. Prepare replacements in memory and write once per update; serialization failures preserve existing files. In-place I/O failures can still leave partial files, and KeyStore/TrustStore writes remain separate (#490, #492). +* Adopt Helper KeyStore/TrustStore changes in memory only after successful writes, and serialize updates per store. Failed updates no longer leak into later writes or block subsequent updates (#490, #525). +* Remove core/native split packages to support the Java module path (#108, #523). + +### Dependencies and build + +* Update gRPC 1.80.0 → 1.85.1, Netty 4.2.9.Final → 4.2.17.Final, Nimbus JOSE JWT 10.9 → 10.10 and Commons Lang 3.20.0 → 3.22.0. Use Guava 33.8.0-jre and remove Commons Validator. +* Update Gradle 9.4.1 → 9.9.1, the Protobuf plugin 0.9.6 → 0.10.1 and the Maven publishing plugin 0.35.0 → 0.37.0. +* Add japicmp checks for public/protected core and provider APIs, excluding internal and generated gRPC packages, and verify native Netty version alignment. Java 8 source/target compatibility is unchanged. ### Documentation -* Document `SpiffeProvider.install()` in the provider README, and explain that the JDK loads the providers declared in `java.security` with the system class loader, so a provider packaged inside an application archive, such as a Spring Boot executable jar, must be installed programmatically -* Fix the JWT source examples in the core README, which called methods and classes that don't exist, document how to configure the source initialization timeouts with `initTimeout`, and document `CachedJwtSource` and JWT-SVID validation with `JwtSvid.parseAndValidate` +* Correct source and JWT examples; document initialization timeouts, serialization, verifier configuration and programmatic provider installation. ## [0.8.17] - 2026-04-20 diff --git a/README.md b/README.md index 2f13d1cf..efad2c48 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,12 @@ X.509 and JWT SVIDs and bundles. **Supports Java 8+** +See the [changelog](CHANGELOG.md) for release notes and upgrade considerations. + Download -------- -The JARs can be downloaded from [Maven Central](https://search.maven.org/search?q=g:io.spiffe%20AND%20v:0.8.17). +The JARs can be downloaded from [Maven Central](https://search.maven.org/search?q=g:io.spiffe%20AND%20v:0.9.0). The dependencies can be added to `pom.xml` @@ -35,7 +37,7 @@ To import the `java-spiffe-provider` component: io.spiffe java-spiffe-provider - 0.8.17 + 0.9.0 ``` The `java-spiffe-provider` component imports the `java-spiffe-core` component. @@ -45,7 +47,7 @@ To just import the `java-spiffe-core` component: io.spiffe java-spiffe-core - 0.8.17 + 0.9.0 ``` @@ -53,12 +55,12 @@ Using Gradle: Import `java-spiffe-provider`: ```gradle -implementation group: 'io.spiffe', name: 'java-spiffe-provider', version: '0.8.17' +implementation group: 'io.spiffe', name: 'java-spiffe-provider', version: '0.9.0' ``` Import `java-spiffe-core`: ```gradle -implementation group: 'io.spiffe', name: 'java-spiffe-core', version: '0.8.17' +implementation group: 'io.spiffe', name: 'java-spiffe-core', version: '0.9.0' ``` ### Bill of Materials (BOM) @@ -66,7 +68,7 @@ implementation group: 'io.spiffe', name: 'java-spiffe-core', version: '0.8.17' The `java-spiffe-bom` artifact manages the versions of all the java-spiffe modules (`java-spiffe-core`, `java-spiffe-provider`, `java-spiffe-helper`, `grpc-netty-linux`, `grpc-netty-macos` and `grpc-netty-macos-aarch64`), so they are declared without a version and always stay aligned with each other. This is especially useful for the -platform-specific `grpc-netty-*` runtime modules described in [MacOS Support](#macos-support), whose version must match +platform-specific `grpc-netty-*` runtime modules described in [Native transport modules](#native-transport-modules), whose version must match the version of `java-spiffe-core`. Import the BOM in the `dependencyManagement` section of the `pom.xml`: @@ -76,7 +78,7 @@ Import the BOM in the `dependencyManagement` section of the `pom.xml`: io.spiffe java-spiffe-bom - 0.8.17 + 0.9.0 pom import @@ -93,10 +95,32 @@ Import the BOM in the `dependencyManagement` section of the `pom.xml`: Using Gradle: ```gradle -implementation platform('io.spiffe:java-spiffe-bom:0.8.17') +implementation platform('io.spiffe:java-spiffe-bom:0.9.0') implementation 'io.spiffe:java-spiffe-provider' ``` +### Native transport modules + +When using the regular JARs, add the transport module for the runtime platform. If its version is pinned separately, +upgrade it with `java-spiffe-core`. The supplied platform-specific fat JARs already include their transport and +service registration. Core discovers the transport through `ServiceLoader`. + +| Platform | Runtime artifact | +|---------------|--------------------------------------------| +| Linux | `io.spiffe:grpc-netty-linux:0.9.0` | +| macOS x86_64 | `io.spiffe:grpc-netty-macos:0.9.0` | +| macOS aarch64 | `io.spiffe:grpc-netty-macos-aarch64:0.9.0` | + +For example, on Linux with Gradle: + +```gradle +runtimeOnly 'io.spiffe:grpc-netty-linux:0.9.0' +``` + +Applications building their own shaded JAR must preserve and merge +`META-INF/services/io.spiffe.workloadapi.internal.GrpcChannelProvider` registrations. For Gradle Shadow, configure +`mergeServiceFiles()`. + ### MacOS Support #### x86 Architecture @@ -108,14 +132,14 @@ In case run on a osx-x86 architecture, add to your `pom.xml`: io.spiffe grpc-netty-macos - 0.8.17 + 0.9.0 runtime ``` Using Gradle: ```gradle -runtimeOnly group: 'io.spiffe', name: 'grpc-netty-macos', version: '0.8.17' +runtimeOnly group: 'io.spiffe', name: 'grpc-netty-macos', version: '0.9.0' ``` #### Aarch64 (M1) Architecture @@ -127,7 +151,7 @@ If you are running the aarch64 architecture (M1 CPUs), add to your `pom.xml`: io.spiffe grpc-netty-macos-aarch64 - 0.8.17 + 0.9.0 runtime ``` @@ -135,7 +159,7 @@ If you are running the aarch64 architecture (M1 CPUs), add to your `pom.xml`: Using Gradle: ```gradle -runtimeOnly group: 'io.spiffe', name: 'grpc-netty-macos-aarch64', version: '0.8.17' +runtimeOnly group: 'io.spiffe', name: 'grpc-netty-macos-aarch64', version: '0.9.0' ``` *Caveat: not all OpenJDK distributions are aarch64 native, make sure your JDK is also running @@ -148,7 +172,7 @@ The `java-spiffe-helper` module manages X.509 SVIDs and Bundles in Java Keystore ### Docker Image -Pull the `java-spiffe-helper` image from `ghcr.io/spiffe/java-spiffe-helper:0.8.17`. +Pull the `java-spiffe-helper` image from `ghcr.io/spiffe/java-spiffe-helper:0.9.0`. For more details, see [java-spiffe-helper/README.md](java-spiffe-helper/README.md). @@ -246,4 +270,4 @@ Based on the OS where the build is run, the `[os-classifier]` will be: * `-linux-x86_64` for Linux * `-osx-x86_64` for MacOS with x86_64 architecture -* `-osx-aarch64` for MacOS with aarch64 architecture (M1) +* `-osx-aarch_64` for MacOS with aarch64 architecture (M1) diff --git a/gradle.properties b/gradle.properties index c5ea6457..68b492f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.8.17 +version=0.9.0 diff --git a/java-spiffe-core/README.md b/java-spiffe-core/README.md index b8f89ea0..0f9240fe 100644 --- a/java-spiffe-core/README.md +++ b/java-spiffe-core/README.md @@ -2,6 +2,8 @@ Core functionality to fetch, process and validate X.509 and JWT SVIDs and Bundles from the Workload API. +For changes affecting existing callers, see [Upgrading to 0.9.0](../CHANGELOG.md#upgrade-considerations). + It uses the [JWT and JOSE Nimbus Library](https://connect2id.com/products/nimbus-jose-jwt) to parse and process the JWT tokens and JSON Web Key (JWK) set bundles. @@ -23,10 +25,11 @@ To create a new X.509 Source: X509Bundle bundle = x509Source.getBundleForTrustDomain(TrustDomain.parse("example.org")); ``` -The `newSource()` method blocks until the X.509 materials can be retrieved from the Workload API and the `X509Source` is -initialized with the X.509 SVIDs and Bundles. A `X.509 context watcher` is configured on the `X509Source` to automatically get -the updates from the Workload API. This watcher performs retries if at any time the connection to the Workload API -reports an error. +The `newSource()` method waits for the initial X.509 SVIDs and bundles, or fails on an initialization error or a +configured timeout. An X.509 context watcher maintains subsequent updates. +Under the default client policy, retryable errors reconnect with backoff; terminal statuses such as +`FAILED_PRECONDITION` end the watch. See the [watch retry changes](../CHANGELOG.md#breaking-changes) +and [source recovery instructions](../CHANGELOG.md#upgrade-considerations). The socket endpoint address is configured through the environment variable `SPIFFE_ENDPOINT_SOCKET`. Another way to configure it is by providing an `X509SourceOptions` instance to the `newSource` method: @@ -45,10 +48,12 @@ It allows to configure another SVID picker. By default, the first SVID is used. ### Configure a timeout for X509Source initialization -The `X509Source newSource()` method blocks waiting until an X.509 context is fetched. The X.509 context fetch is retried -using an exponential backoff policy with this progression of delays between retries: 1 second, 2 seconds, 4, 8, 16, 32, 60, 60, 60... -It retries indefinitely unless a timeout is configured. This includes `PERMISSION_DENIED`, so an unregistered -workload waits for registration instead of failing immediately. Set a nonzero `initTimeout` to bound this wait. +The `newSource()` method waits for the initial X.509 context. A zero initialization timeout means there is no +deadline; it does not make terminal errors retryable. Under the default policy, retryable errors use exponential +backoff with delays of 1, 2, 4, 8, 16, 32, then 60 seconds between attempts. An initial `PERMISSION_DENIED` can retry +indefinitely while an unregistered workload waits for registration. A terminal status such as `FAILED_PRECONDITION` +can fail initialization immediately with `X509SourceException`, even with a zero timeout. Set a nonzero `initTimeout` +to bound the wait for retryable failures. This timeout can be configured either with the `initTimeout` option of the `X509SourceOptions` passed to the `newSource(X509SourceOptions options)` method: @@ -91,10 +96,12 @@ To create a new JWT Source: JwtBundle bundle = jwtSource.getBundleForTrustDomain(TrustDomain.parse("example.org")); ``` -The `newSource()` method blocks until the JWT materials can be retrieved from the Workload API and the `JwtSource` is -initialized with the JWT Bundles. A `JWT context watcher` is configured on the JwtSource to automatically get -the updates from the Workload API. This watcher performs retries if at any time the connection to the Workload API -reports an error. +The `newSource()` method waits for the initial JWT bundles, or fails on an initialization error or a configured +timeout. A JWT bundle watcher maintains subsequent updates. +Under the default client policy, retryable errors reconnect with backoff; terminal statuses such as +`FAILED_PRECONDITION` end the watch. The same initialization and watch behavior applies to `CachedJwtSource`. +See the [watch retry changes](../CHANGELOG.md#breaking-changes) +and [source recovery instructions](../CHANGELOG.md#upgrade-considerations). The socket endpoint address is configured through the environment variable `SPIFFE_ENDPOINT_SOCKET`. @@ -124,10 +131,12 @@ the cached JWT-SVIDs have passed half of their lifetime. ### Configure a timeout for JwtSource initialization -The `JwtSource newSource()` method blocks until the JWT materials are fetched. The fetching process is retried -using an exponential backoff policy with this progression of delays between retries: 1 second, 2 seconds, 4, 8, 16, 32, 60, 60, 60... -It retries indefinitely unless a timeout is configured. This includes `PERMISSION_DENIED`, so an unregistered -workload waits for registration instead of failing immediately. Set a nonzero `initTimeout` to bound this wait. +`DefaultJwtSource.newSource()` and `CachedJwtSource.newSource()` wait for the initial JWT bundles. A zero +initialization timeout means there is no deadline; it does not make terminal errors retryable. Under the default +policy, retryable errors use exponential backoff with delays of 1, 2, 4, 8, 16, 32, then 60 seconds between attempts. +An initial `PERMISSION_DENIED` can retry indefinitely while an unregistered workload waits for registration. +A terminal status such as `FAILED_PRECONDITION` can fail initialization immediately with `JwtSourceException`, +even with a zero timeout. Set a nonzero `initTimeout` to bound the wait for retryable failures. This timeout can be configured either with the `initTimeout` option of the `JwtSourceOptions` passed to the `newSource(JwtSourceOptions options)` method: diff --git a/java-spiffe-helper/README.md b/java-spiffe-helper/README.md index 863c9feb..f0eefa97 100644 --- a/java-spiffe-helper/README.md +++ b/java-spiffe-helper/README.md @@ -6,15 +6,37 @@ in a separated TrustStore in disk. The Helper automatically gets the SVID updates and stores them in the KeyStore and TrustStore. +Before upgrading from 0.8.17, move manually installed trusted certificates that must be retained to aliases outside +`.`. Matching entries can be deleted on the first Helper update even if the +Helper did not create them. See the [0.9.0 upgrade instructions](../CHANGELOG.md#upgrade-considerations) for this risk, stale authority cleanup +and failure exit handling. + ## Usage On Linux: -`java -jar java-spiffe-helper-0.8.17-linux-x86_64.jar` +`java -jar java-spiffe-helper-0.9.0-linux-x86_64.jar` + +For macOS, build the Helper locally from the repository root on the target architecture. The tag release workflow +builds the published Helper JAR on Ubuntu; the macOS examples below use locally built JARs. + +```sh +./gradlew :java-spiffe-helper:shadowJar +``` + +The output is written to `java-spiffe-helper/build/libs/` with a classifier for the build host. -On Mac OS: +On macOS x86_64, run the locally built JAR: -`java -jar java-spiffe-helper-0.8.17-osx-x86_64.jar` +```sh +java -jar java-spiffe-helper/build/libs/java-spiffe-helper-0.9.0-osx-x86_64.jar +``` + +On macOS aarch64, run the locally built JAR: + +```sh +java -jar java-spiffe-helper/build/libs/java-spiffe-helper-0.9.0-osx-aarch_64.jar +``` You can run the utility with the `-c` or `--config` option to specify the path to the configuration file. By default, it will look for a configuration file named `conf/java-spiffe-helper.properties` in the current working directory. diff --git a/java-spiffe-provider/README.md b/java-spiffe-provider/README.md index 9fc18e2f..70862729 100644 --- a/java-spiffe-provider/README.md +++ b/java-spiffe-provider/README.md @@ -3,6 +3,9 @@ This module provides a Java Security Provider implementation supporting X.509-SVIDs and methods for creating `SSLContext` that are backed by the Workload API. +Before upgrading from 0.8.17, review the [0.9.0 upgrade instructions](../CHANGELOG.md#upgrade-considerations), especially the stricter TLS peer +validation and the order in which `SpiffeIdVerifier` is called. + ## Create an SSL Context backed by the Workload API To create an `javax.net.ssl.SSLContext` that is backed by the Workload API through a `X509Source`, having the environment variable