fix: normalize PEM line endings in signing key validation

This commit is contained in:
lincube
2026-04-20 08:55:45 +08:00
parent 48ce93b68e
commit 1e6b61db85

View File

@@ -372,8 +372,12 @@ jobs:
Set-Content -Path $publicKeyPath -Value $derivedPublicKey -NoNewline
$repoPublicKeyPath = "LanMountainDesktop.Launcher/Assets/public-key.pem"
$repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw).Trim()
if ($repoPublicKey -ne $derivedPublicKey.Trim()) {
$repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw)
$normalizePem = {
param([string]$pem)
return (($pem -replace "`r`n", "`n" -replace "`r", "`n").Trim())
}
if (& $normalizePem $repoPublicKey -ne (& $normalizePem $derivedPublicKey)) {
Write-Error "Configured signing private key does not match $repoPublicKeyPath. Keep keypair consistent before publishing."
exit 1
}
@@ -658,8 +662,12 @@ jobs:
Set-Content -Path $publicKeyPath -Value $derivedPublicKey -NoNewline
$repoPublicKeyPath = "LanMountainDesktop.Launcher/Assets/public-key.pem"
$repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw).Trim()
if ($repoPublicKey -ne $derivedPublicKey.Trim()) {
$repoPublicKey = (Get-Content -Path $repoPublicKeyPath -Raw)
$normalizePem = {
param([string]$pem)
return (($pem -replace "`r`n", "`n" -replace "`r", "`n").Trim())
}
if (& $normalizePem $repoPublicKey -ne (& $normalizePem $derivedPublicKey)) {
Write-Error "Configured signing private key does not match $repoPublicKeyPath. Keep keypair consistent before publishing."
exit 1
}