Integrate parameter validation for Azure Key Vault client auth#375
Open
AsmCord wants to merge 8 commits intovcsjones:mainfrom
Open
Integrate parameter validation for Azure Key Vault client auth#375AsmCord wants to merge 8 commits intovcsjones:mainfrom
AsmCord wants to merge 8 commits intovcsjones:mainfrom
Conversation
Removed TODO comment regarding certificate thumbprint authentication support.
vcsjones
reviewed
Mar 2, 2026
| return new AzureKeyVaultMaterializedConfiguration(credential, certificate, keyId); | ||
| } | ||
|
|
||
| private X509Certificate2 LoadCertificateByThumbprint(string thumbprint, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation) |
Owner
There was a problem hiding this comment.
Does this compile without warning? I would expect the nullability analyzer to be complaining about returning null from a non-null returning method.
Suggested change
| private X509Certificate2 LoadCertificateByThumbprint(string thumbprint, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation) | |
| private X509Certificate2? LoadCertificateByThumbprint(string thumbprint, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation) |
Author
There was a problem hiding this comment.
I missed the #nullable enable pragma in the file. I adapted the null handling
| else if (!string.IsNullOrWhiteSpace(configuration.AzureCertificateThumbprint)) | ||
| { | ||
| string certificateThumbPrint = configuration.AzureCertificateThumbprint; | ||
| X509Certificate2 clientCertificate = LoadCertificateByThumbprint(certificateThumbPrint, StoreLocation.CurrentUser); |
Owner
There was a problem hiding this comment.
Would it make sense to try the LocalMachine store if it couldn't find one in CurrentUser?
Suggested change
| X509Certificate2 clientCertificate = LoadCertificateByThumbprint(certificateThumbPrint, StoreLocation.CurrentUser); | |
| X509Certificate2? clientCertificate = LoadCertificateByThumbprint(certificateThumbPrint, StoreLocation.CurrentUser); | |
| clientCertificate ??= LoadCertificateByThumbprint(certificateThumbPrint, StoreLocation.LocalMachine); |
| } | ||
|
|
||
| if (KeyVaultClientId is not null && KeyVaultClientSecret is null) | ||
| if (KeyVaultClientId is not null && KeyVaultClientSecret is null && KeyVaultClientAuthCertificate is null) |
Owner
There was a problem hiding this comment.
It would be nice if we did some validation on the thumbprint here to catch typos. Something like:
static bool IsValidHex(string input)
{
if (input is not { Length: 40 })
{
return false;
}
foreach (char c in input)
{
switch (c)
{
case >= 'a' and <= 'f':
case >= 'A' and <= 'F':
case >= '0' and <= '9':
continue;
default:
return false;
}
}
return true;
}If it returns false then we should write an error to the context.
Co-authored-by: Kevin Jones <vcsjones@github.com>
… into main_adapted
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New options allows more control which computer can sign and use the codesigning certificate, because it does not depend on the knowledge of the secret in the build pipeline
Integrate the ability to use a dedicated certificate to secure and validate the communication between the caller of the AzureSignTool (typically a build machine) and the Key Vault which might be located elsewhere.
Add new parameter options to control the behavior.