Skip to content

Add CA bundle version and pinning status to user agent string#109

Open
mihir-pradhan wants to merge 1 commit into
masterfrom
ztcapin-479
Open

Add CA bundle version and pinning status to user agent string#109
mihir-pradhan wants to merge 1 commit into
masterfrom
ztcapin-479

Conversation

@mihir-pradhan

@mihir-pradhan mihir-pradhan commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Description

  • Added CA_BUNDLE_VERSION = "1.0" constant in Http.java
  • Modified the legacy constructor and ClientBuilder.build() to append ca_bundle/1.0 and (ca_pinning=enabled|disabled) to the user agent string based on the disableCaPinning runtime state
  • The pinning status is derived from the same disableCaPinning flag that configures TLS, so the reported value always matches the client's actual pinning state

How Has This Been Tested?

  • testDefaultBuilder_includesCaBundleVersion — verifies ca_bundle/1.0 is present in the user agent
  • testDefaultBuilder_includesCaPinningEnabled — verifies (ca_pinning=enabled) when pinning is not disabled
  • testDisableCaPinning_includesCaPinningDisabled — verifies (ca_pinning=disabled) when disableCaPinning() is called
  • testLegacyConstructor_includesCaBundleAndPinningEnabled — verifies both fields present via the deprecated constructor path

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment on lines +684 to 698
String caPinningStatus = disableCaPinning ? "disabled" : "enabled";
duoClient.setHeader("user-agent", String.format("%s ca_bundle/%s (ca_pinning=%s)",
UserAgentString, CA_BUNDLE_VERSION, caPinningStatus));
if (disableCaPinning) {
duoClient.disableCaPinning();
}
if (additionalDuoHeaders != null) {
duoClient.addAdditionalDuoHeader(additionalDuoHeaders);
}
if (headers != null) {
for (String name : headers.keySet()) {
String value = headers.get(name);
duoClient.addHeader(name, value);
}
}

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.

There's a preexisting issue here; if a consumer calls addHeader to set user-agent, then this logic will add an additional user-agent header, which is undefined behavior depending on the server.

As an improvement, if we move the newly added duoClient.setHeader("user-agent"... logic down to after the if (headers != null) { block, then the setHeader will overwrite any custom set user-agent. It's not ideal to lose the user-agent, but it's better than the undefined behavior of having multiple ones. This also better matches our other sdk behavior.

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.

2 participants