'MAUI Blazor Cannot EV Code Sign with YubiKey

I am trying to code sign my MAUI Blazor (Windows) app using my EV Code signing cert. I have installed my cert on a YubiKey 5 FIPS device. When I run the below command the app starts to build. Then when it's time to sign the package I am asked for my pin (for the YubiKey). Once the pin is entered I get the below exception.

Command:

"C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\msbuild" /restore /t:Publish /p:TargetFramework=net6.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint="KeyThumbprint" /p:PackageCertificatePassword="password"

Exception:

C:\Users\user\.nuget\packages\microsoft.windowsappsdk\1.0.0\build\Microsoft.Build.Msix.Packaging.targets(462,5): error
 APPX1204: Failed to sign 'path/to/my.msix'
. SignTool Error: An unexpected internal error has occurred. [path/to/my/project.csproj]
C:\Users\user\.nuget\packages\microsoft.windowsappsdk\1.0.0\build\Microsoft.Build.Msix.Packaging.targets(462,5): error
 APPX1204:  [path/to/my/project.csproj]

Also, if I try the code singing tool I get the below error:

"Error: SignerSign() failed." (-2146435068/0x80100004)

Code Sign.exe Command

signtool.exe sign /fd sha256 /a /sha1 my_thumbprint "path/to/my.msix"

In the past I have gotten a self signed code signint cert to work. This would indicate that the above command is correct.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source