Skip to content

Conversation

@vcolin7
Copy link
Member

@vcolin7 vcolin7 commented Jan 27, 2026

Description

Fixes: #43451

Fixed an issue where cryptographic operation results (SignResult, EncryptResult, DecryptResult, WrapResult, UnwrapResult) returned a versionless key ID instead of the full versioned key ID returned by the service. This caused issues when attempting roundtrip scenarios, as callers couldn't determine which key version was used for the original operation (e.g. Sign -> Verify).

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@vcolin7 vcolin7 requested review from heaths and samvaity January 27, 2026 22:11
@vcolin7 vcolin7 self-assigned this Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

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 fixes Key Vault cryptography operation results to return the service-returned (versioned) key identifier (kid) instead of the client’s (potentially unversioned) keyId, enabling correct roundtrip scenarios when key rotation is used (e.g., sign→verify, wrap→unwrap).

Changes:

  • Updated EncryptResult to use KeyOperationResult.getKid() for keyId.
  • Updated DecryptResult to use KeyOperationResult.getKid() for keyId.
  • Updated SignResult, WrapResult, and UnwrapResult to use KeyOperationResult.getKid() for keyId.

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

Given your changelog entry, this would seem right but without seeing any tests or knowing your code from memory, does getKid() return the full URI including version? Might be good to add a test or even an assertion to existing tests to make sure you do indeed have a version.

@vcolin7
Copy link
Member Author

vcolin7 commented Jan 28, 2026

@heaths Added a few more check to our unit tests, including one for kid version

// Ensure the keyId includes the key version
String[] keyIdParts = keyId.split("/");

assertTrue(keyIdParts.length >= 5 && !keyIdParts[4].isEmpty(), "keyId does not contain key version.");
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this works, but don't you have an ID parser like we added to all other languages? Might be nice to use that for maintainability so it's obvious that the version is being checked: parse it into its components, and check a version local. Just a suggestion. Non-blocking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, you're right! I forgot we had that. Thanks for reminding me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

[BUG] SignResult keyId is missing the version information of the key used

3 participants