Skip to content

[improve][client] Use SHA-256 for generated reader subscription names#26153

Merged
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:fips-qw-reader-subscription-hash
Jul 9, 2026
Merged

[improve][client] Use SHA-256 for generated reader subscription names#26153
david-streamlio merged 2 commits into
apache:masterfrom
david-streamlio:fips-qw-reader-subscription-hash

Conversation

@david-streamlio

@david-streamlio david-streamlio commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Motivation

When a reader is created without an explicit subscription name, ReaderImpl/MultiTopicsReaderImpl generate one by hashing a random UUID with SHA-1 (DigestUtils.sha1Hex). The hash is not a security control — it just produces a short random identifier — but strict security providers reject SHA-1: under BC-FIPS in approved-only mode the call throws, so creating a reader without a subscription name fails on FIPS-configured JVMs.

This is one of a set of small preparatory cleanups for FIPS-restricted deployments; a broader PIP is being drafted separately.

Modifications

Replaced DigestUtils.sha1Hex(...) with DigestUtils.sha256Hex(...) in the generated-subscription-name paths of ReaderImpl and MultiTopicsReaderImpl. The generated names keep the same shape (reader- / multiTopicsReader- prefix + 10 hex chars) and entropy (40 bits of a hash over a random UUID). The names are ephemeral, used for non-durable subscriptions, and never persisted, so nothing is observable across versions.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage. (Existing reader tests, e.g. ReaderImplTest, exercise the generated-name path.)

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

The auto-generated reader subscription name hashed a random UUID with
SHA-1. The hash is not a security control, but SHA-1 is rejected by strict
security providers (e.g. BC-FIPS in approved-only mode), which would make
readers without an explicit subscription name fail on FIPS-configured JVMs.
The generated names are ephemeral and never persisted, so the change is not
observable across versions.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Pulsar client compatibility with FIPS-restricted JVMs by removing SHA-1 usage from autogenerated reader subscription names, which can fail under strict security providers.

Changes:

  • Switch ReaderImpl autogenerated subscription name hashing from SHA-1 to SHA-256.
  • Switch MultiTopicsReaderImpl autogenerated subscription name hashing from SHA-1 to SHA-256 (keeping the same prefix + 10-hex-char shape).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pulsar-client/src/main/java/org/apache/pulsar/client/impl/ReaderImpl.java Replace DigestUtils.sha1Hex(...) with DigestUtils.sha256Hex(...) for generated reader subscription names.
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsReaderImpl.java Replace DigestUtils.sha1Hex(...) with DigestUtils.sha256Hex(...) for generated multi-topic reader subscription names.

@david-streamlio
david-streamlio merged commit 73d61e4 into apache:master Jul 9, 2026
43 checks passed
@david-streamlio
david-streamlio deleted the fips-qw-reader-subscription-hash branch July 9, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants