Skip to content

[BUG] CreateKeyAsync only Creates keys with default size/curve and ignores key options input #50478

@ventimdg-msft

Description

@ventimdg-msft

Library name and version

Azure.Security.KeyVault.Keys 4.7.0

Describe the bug

public virtual async Task<Response> CreateKeyAsync(string name, KeyType keyType, CreateKeyOptions keyOptions = default, CancellationToken cancellationToken = default)

This function says that it "Creates and stores a new key in Key Vault. The create key operation can be used to create any key type in Azure Key Vault." However, the KeyOptions are not parsed correctly, causing RSA/Oct keys to always have default size and ECC keys to always have the default Curve, regardless if it is set in the options.

Image

the call to var parameters = new KeyRequestParameters(keyType, keyOptions); navigates here

Image

In this code, the is no parsing of the keytype to determine whether key size or curve needs to be set. This results in all keys created with the function to return keys with a default size/curve

Expected behavior

If you put in a key type and define the key options, a key is created of the input type with the size/curve defined in the key options input

Actual behavior

Key of proper type is created, but KeySize/Curve input in the options is dropped if it is included and default value is used

Reproduction Steps

Call this function with any key options and observe that the size/curve will not change in the returned key

public virtual async Task<Response> CreateKeyAsync(string name, KeyType keyType, CreateKeyOptions keyOptions = default, CancellationToken cancellationToken = default)

Environment

NET 4.7.2 and NET8

Metadata

Metadata

Labels

ClientThis issue is related to a non-management packageKeyVaultcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Untriaged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions