-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Azure Trusted Signing on Docker #8649
Comments
Correct, it's trying to boot a parallels VM as it's configured to use powershell and that's not in the default electron-builder-provided docker image. This has always been the logic though for accessing powershell commands What does your JSign solution look like? Do you have a gist or public repo you could link? |
@mmaietta Thanks for your answer. I guess my workflow never used powershell commands previously, so I never hit that bit of logic. Now that powershell is available for Linux, is there any chance that that could be used ? My solution with JSign is pretty simple (though I had to use the snapshot build of JSign 7.0 as 6.0 does not support Azure Trusted Signing, and 7.0 is not out yet) (The relevant part of) my build config: {
/*...*/
win: {
signtoolOptions: {
publisherName: 'My Publisher',
signingHashAlgorithms: ['sha256'], // only sign sha256, no need to sign sha1 that was for windows 7 which we do not support anyway
sign: (process.env.AZURE_CODESIGNING_ACCESS_TOKEN && process.env.AZURE_CODESIGNING_PROFILE) ? './scripts/sign-win.js' : null
}
}
} With exports.default = async function (configuration) {
require('child_process').execSync(
`jsign --storetype TRUSTEDSIGNING --keystore weu.codesigning.azure.net --storepass ${process.env.AZURE_CODESIGNING_ACCESS_TOKEN} --alias ${process.env.AZURE_CODESIGNING_PROFILE} "${configuration.path}"`,
{
stdio: 'inherit'
}
)
} The script to run the build with signature: az login --service-principal --tenant ${AZURE_TENANT} -u ${AZURE_SERVICE_PRINCIPAL_ID} -p ${AZURE_SERVICE_PRINCIPAL_SECRET}
export AZURE_CODESIGNING_ACCESS_TOKEN=$(az account get-access-token --resource https://codesigning.azure.net | jq -r '.accessToken')
npm run release:limbo -- --targetPlatform=win32 --targetType=nsis All this on a custom docker image to have all tools: FROM electronuserland/builder:20-wine-07.24
RUN apt-get update
RUN apt-get install -y azure-cli jq
# From https://github.com/ebourg/jsign/actions/runs/11514023277
ADD jsign_7.0~SNAPSHOT_all.deb /tmp/
RUN apt-get install -y /tmp/jsign_7.0~SNAPSHOT_all.deb
RUN apt-get clean autoclean
RUN apt-get autoremove -y
RUN rm -rf /var/lib/{apt,dpkg,cache,log}/ /tmp/jsign_7.0~SNAPSHOT_all.deb |
AFAICT, there are only Microsoft-provided docker images w/ powershell available. I haven't been able to locate any docker image scripts or dockerfiles that install powershell core themselves. |
@mmaietta I just did it without problem, on apt-get update
apt-get install -y apt-transport-https software-properties-common
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt-get update
apt-get install -y powershell |
Nice find! Okay, now that we have powershell installed, we need these commands to successfully execute
Using command line:
It seems to run successfully for me on a local image, would love for you to try it out from your side as well. Just need to figure out how to discern we're in a docker container and not needing to execute on a parallels VM |
First command fails for me :
Second one succeeds though. Microsoft's doc seems to also require I am a complete novice in this powershell / microsoft build tools stuff ^^ |
@arantes555 I think I was able to set it up correctly, but I'm hesitant on adding powershell to the default I'm thinking of implementing the compatibility for Trusted Signing, but requiring that you provide the docker image with electron-builder/packages/app-builder-lib/src/vm/DockerVm.ts Lines 10 to 20 in 6187ac8
We already take a similar approach with What are your thoughts? |
Great ! About adding powershell, maybe you could try adding it to the
Not a fan of basing the logic on detecting if we are in a docker container .. What if I am on a desktop linux (or mac) which has powershell locally ? It could use it, but it's gonna try booting a VM. My suggestion: if not on windows, try detecting if function isAvailable (name) {
try {
exec('which', [name])
return true
} catch {
return false
}
} If it's available, use local pwsh, if not boot VM. However, you are much more familiar that I am with the internals of electron-builder, so if your approach is easier to implement, let's go for it, it would still be much better ! |
25.1.8
&26.0.0-alpha.4
v20.15.1
in dockerelectronuserland/builder:wine-mono
I am trying to use the new Azure Trusted Signing on a (linux) docker container, using the
electronuserland/builder:wine
orelectronuserland/builder:wine-mono
image.This fails with the below errors.
On 25.1.8:
On 26.0.0-alpha.4:
Digging into the relevant code, it looks like it's trying to boot a Parallels VM.
Is it currently impossible to use Azure Trusted Signing on the Docker build image, or any unix system ? I did not find any warning about it in the documentation.
(For anyone interested, I did manage to find a -convoluted- workaround using JSign)
The text was updated successfully, but these errors were encountered: