Я искал все, что мог придумать, и не могу найти решения. У меня есть приложение ClickOnce, которое я пытаюсь подписать с помощью сертификата, созданного нашим внутренним центром сертификации. На моем локальном компьютере я могу подписать код без проблем, но при попытке создать конвейер Azure я начал сталкиваться с проблемами.
Сначала я попробовал обычный способ проверки подписи ClickOnce проявляется в VisualStudio. Затем я выбрал сертификат и ввел пароль. Сертификат был импортирован в хранилище сертификатов, и я смог построить на своем локальном компьютере.
When running the pipeline in Azure, I got an error that due to the password, the certificate couldn't be imported. So I added the .pfx file in the Azure Library as a secure file, and added two tasks to my pipeline - one to download the secure file, and a Powershell task to import the cert. Once the cert was being imported successfully, my VSBuild task started failing with the following error.
An error occurred while signing: Failed to sign {AppName.exe}. SignTool Error: The signer's certificate is not valid for signing.
Most of the Google results for this error are due to an expired cert, but the cert I'm using was just generated within the past month and the expiration is several years out.
I have attempted countless different ways of getting this app to sign, all of which have resulted in the same error. Some of these attempts include:
- using MSBuild task instead of VisualStudio Build
- unchecked the 'Sign ClickOnce' and added custom targets in the .csproj file to execute commands for signtool.exe so I could fine tune which parameters to pass
- use a Powershell script after the build (with no signing) to attempt to sign the manifests using Mage.exe
I've discussed this with our server admin and our Active Directory group and haven't had any luck getting this resolved as our organization primarily does web applications. This is the only clickonce application that I'm aware of in our organization.
This app has been around since 2013 and is only used by in house staff, but has recently been getting quarantined by Symantec because it's not signed, so I need to figure out how to sign it and get it to build in DevOps.
Our pipelines use an On Prem server (Server 2012 R2) if that helps determine the issue.
EDIT: To include a sample of the custom targets I've tried in the .csproj. This was my latest attempt where I added a timestamp url. I originally attempted without the timestamp server.
Also, I tried commenting out the AfterCompile target. The build would get past that part, and it would actually sign the manifest successfully using mage.exe, but then would fail on the last command that uses signtool.exe to sign the setup.exe. It seems that the issue is with signtool.exe and not necessarily an issue with the certificate since mage.exe can sign with it.
<PropertyGroup>
<CertPath>
</CertPath>
<CertPass>
</CertPass>
</PropertyGroup>
<Target Name="AfterCompile" Condition="'$(Configuration)|$(Platform)' != 'Debug|x86' ">
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /f "$(CertPath)" /fd sha256 /p $(CertPass) /v /t "http://timestamp.comodoca.com?td=sha256" "$(ProjectDir)obj\$(Platform)\$(ConfigurationName)\$(TargetFileName)"" />
</Target>
<Target Name="SignManifest" AfterTargets="_DeploymentSignClickOnceDeployment" Condition="'$(Configuration)|$(Platform)' != 'Debug|x86' ">
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\mage.exe" -Sign "$(_DeploymentApplicationDir)$(_DeploymentTargetApplicationManifestFileName)" -cf $(CertPath) -pwd $(CertPass)" />
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\mage.exe" -Update "$(PublishDir)$(TargetDeployManifestFileName)" -AppManifest "$(_DeploymentApplicationDir)$(_DeploymentTargetApplicationManifestFileName)"" />
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.7.2 Tools\mage.exe" -Sign "$(PublishDir)$(TargetDeployManifestFileName)" -cf $(CertPath) -pwd $(CertPass)" />
<Exec Command=""C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\signtool.exe" sign /f $(CertPath) /fd sha256 /p $(CertPass) /v /t "http://timestamp.comodoca.com?td=sha256" "$(PublishDir)\setup.exe"" />
</Target>
И соответствующий раздел журнала сборки.
введите описание изображения здесь