Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/Commands/AzureAD/RegisterAzureADApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,12 +471,6 @@ private X509Certificate2 GetCertificate(PSObject record)
{
throw new PSArgumentNullException(nameof(CertificatePassword), $"Failed to import private key certificate. Ensure the correct password is provided for parameter: {nameof(CertificatePassword)}");
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The error message states 'Failed to import private key certificate' but uses PSArgumentNullException, which is semantically incorrect as this is not about a null argument but rather an incorrect password. Consider using PSArgumentException instead to better reflect the actual error condition. Note: This issue exists in the current code and is not introduced by this PR, but since the surrounding code is being modified, it would be appropriate to fix this as well.

Suggested change
throw new PSArgumentNullException(nameof(CertificatePassword), $"Failed to import private key certificate. Ensure the correct password is provided for parameter: {nameof(CertificatePassword)}");
throw new PSArgumentException($"Failed to import private key certificate. Ensure the correct password is provided for parameter: {nameof(CertificatePassword)}", nameof(CertificatePassword));
Copilot uses AI. Check for mistakes.
}

// Ensure the certificate at the provided CertificatePath holds a private key
if (!cert.HasPrivateKey)
{
throw new PSArgumentException(string.Format(Resources.CertificateAtPathHasNoPrivateKey, CertificatePath), nameof(CertificatePath));
}
}
else
{
Expand Down
Loading