Class CertificateRotationTracker (2.91.0)

public class CertificateRotationTracker

Thread-safe helper that tracks workload certificate fingerprints on disk to detect mTLS certificate rotations for transport channels (ChannelPool and RefreshingHttpJsonChannel).

For internal use only.

Inheritance

java.lang.Object > CertificateRotationTracker

Constructors

CertificateRotationTracker(@Nullable String workloadCertPath)

public CertificateRotationTracker(@Nullable String workloadCertPath)

Creates a tracker for a fixed workload certificate path using WorkloadCertificateUtils#getCertificateFingerprint(String).

Parameter
Name Description
workloadCertPath @org.jspecify.annotations.Nullable java.lang.String

CertificateRotationTracker(Supplier<String> certPathSupplier, Function<String,String> fingerprintReader)

public CertificateRotationTracker(Supplier<String> certPathSupplier, Function<String,String> fingerprintReader)

Creates a tracker with custom certificate path and fingerprint suppliers (used by transports that expose package-private overrides for testing).

Parameters
Name Description
certPathSupplier Supplier<String>
fingerprintReader Function<String,String>

Methods

getActiveCertFingerprint()

public String getActiveCertFingerprint()

Returns the currently active certificate fingerprint (or "" if none).

Returns
Type Description
String

invalidateCache()

public void invalidateCache()

Invalidates the cached disk check result. Visible for testing.

isAlreadyActive(String diskFingerprint)

public boolean isAlreadyActive(String diskFingerprint)

Returns true if diskFingerprint matches the currently active certificate fingerprint.

Parameter
Name Description
diskFingerprint String
Returns
Type Description
boolean

markRefreshed(String newFingerprint)

public void markRefreshed(String newFingerprint)

Updates the active certificate fingerprint after a successful channel refresh and clears any cached disk check result.

This holds diskCheckLock so that a disk check already in progress cannot write its (possibly old) result back to the cache after the switch.

Parameter
Name Description
newFingerprint String

readDiskFingerprint()

public String readDiskFingerprint()

Reads the current certificate fingerprint directly from disk (bypassing the 1-second cache), returning "" if no workload certificate path is configured or if the file is currently unreadable/empty.

Returns
Type Description
String

shouldRefresh()

public boolean shouldRefresh()

Returns true if a workload certificate path is configured, readable, and its current SHA-256 fingerprint on disk differs from the active fingerprint.

Returns
Type Description
boolean