[BUG] SignResult keyId is missing the version information of the key used #43451
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
KeyVault
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Describe the bug
In the .NET implementation of the Cryptography client, the SignResult for the signData action returns the full key used to create the signature as the keyId, as this information is relevant to verifying the signature on the other side against the correct key.
However, if you use the same call in the Java implementation of the Cryptography client, you only ever get back the versionless key that was used to create the Cryptography client.
Currently, it is not possible to use keys with key rotation due to the missing version specification, as the recipient cannot be informed which key was used for the signature.
If the recipient also uses the versionless key ID, the verify call returns false
Exception or Stack Trace
No Exception
To Reproduce
Code Snippet
Expected behavior
Both implementations should always return the full KeyId, as this is required to verify the signature correctly.
If key rotation is configured, the signature will otherwise be recognized as invalid if the verification is performed against a KeyUri without a version.
Screenshots
If applicable, add screenshots to help explain your problem.
Setup (please complete the following information):
If you suspect a dependency version mismatch (e.g. you see
NoClassDefFoundError
,NoSuchMethodError
or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:mvn dependency:tree -Dverbose
)Additional context
According to my research so far, the problem could be solved quite simply at this point in the code
The KeyOperationResult received back here contains the correct and complete kid including version.
Therefore, instead of
return new SignResult(result.getResult(), algorithm, keyId);
actuallyreturn new SignResult(result.getResult(), algorithm, result.getKid());
should be used in order to be able to use key rotation for sign and verify actions within the java implementationThis could also apply to the return values for methods like
decrypt
,verify
,wrapKey
andunwrapKey
since they als use keyId within the return value.Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
The text was updated successfully, but these errors were encountered: