Skip to content

Commit d881465

Browse files
author
LoukaO
committed
Fix Linux binary signing - replace osslsigncode with SHA256 checksums
- Remove osslsigncode usage for Linux binaries (incompatible with ELF format) - Add SHA256 checksum generation for integrity verification - Add build metadata file with version and build information - Update artifact uploads to include checksums and metadata - Improves Linux build reliability and follows standard practices
1 parent 17443fc commit d881465

File tree

1 file changed

+21
-120
lines changed

1 file changed

+21
-120
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -205,134 +205,33 @@ jobs:
205205
objcopy --add-section .version=version.txt terminusai-linux-amd64
206206
rm version.txt
207207
208-
- name: Sign Linux binary
209-
if: ${{ vars.ENABLE_SIGNING == 'true' }}
208+
- name: Create Linux binary checksum and metadata
210209
run: |
211-
# Install signing tools
212-
sudo apt-get update
213-
sudo apt-get install -y openssl file build-essential cmake libssl-dev libcurl4-openssl-dev
214-
215-
# Build osslsigncode from source for better compatibility
216-
echo "Building osslsigncode from source..."
217-
timeout 300 git clone --depth 1 https://github.com/mtrojnar/osslsigncode.git || {
218-
echo "Failed to clone osslsigncode, falling back to package version"
219-
sudo apt-get install -y osslsigncode
220-
}
221-
222-
if [ -d "osslsigncode" ]; then
223-
cd osslsigncode
224-
timeout 600 bash -c "
225-
mkdir -p build && cd build &&
226-
cmake -S .. -B . &&
227-
cmake --build . &&
228-
sudo cmake --install .
229-
" || {
230-
echo "Source build failed, falling back to package version"
231-
cd ..
232-
sudo apt-get install -y osslsigncode
233-
}
234-
cd ..
235-
fi
236-
237-
# Verify installation
238-
osslsigncode --version || echo "osslsigncode installed but version check failed"
239-
240-
# Decode certificate and detect format
241-
echo "${{ secrets.CERTIFICATE_BASE64 }}" | base64 --decode > certificate.bin
242-
243-
# Check certificate format
244-
file_info=$(file certificate.bin)
245-
echo "Certificate format detected: $file_info"
246-
247-
# Try different certificate formats
248-
cert_converted=false
249-
250-
# Try as PKCS#12 first
251-
if openssl pkcs12 -info -in certificate.bin -noout -passin pass: 2>/dev/null; then
252-
echo "Certificate is PKCS#12 format"
253-
openssl pkcs12 -in certificate.bin -out cert.pem -nodes -passin pass:
254-
openssl pkcs12 -in certificate.bin -nocerts -out key.pem -nodes -passin pass:
255-
cert_converted=true
256-
elif [ -n "${{ secrets.CERTIFICATE_PASSWORD }}" ] && openssl pkcs12 -info -in certificate.bin -noout -passin pass:"${{ secrets.CERTIFICATE_PASSWORD }}" 2>/dev/null; then
257-
echo "Certificate is password-protected PKCS#12 format"
258-
openssl pkcs12 -in certificate.bin -out cert.pem -nodes -passin pass:"${{ secrets.CERTIFICATE_PASSWORD }}"
259-
openssl pkcs12 -in certificate.bin -nocerts -out key.pem -nodes -passin pass:"${{ secrets.CERTIFICATE_PASSWORD }}"
260-
cert_converted=true
261-
# Try as PFX (another name for PKCS#12)
262-
elif openssl pkcs12 -info -in certificate.bin -noout 2>/dev/null; then
263-
echo "Certificate is PFX format"
264-
openssl pkcs12 -in certificate.bin -out cert.pem -nodes
265-
openssl pkcs12 -in certificate.bin -nocerts -out key.pem -nodes
266-
cert_converted=true
267-
# Try as DER certificate
268-
elif openssl x509 -inform DER -in certificate.bin -noout 2>/dev/null; then
269-
echo "Certificate is DER format (certificate only, no private key)"
270-
echo "WARNING: DER format certificate detected but no private key available for signing"
271-
echo "Linux signing requires both certificate and private key - skipping"
272-
# Try as PEM certificate
273-
elif openssl x509 -inform PEM -in certificate.bin -noout 2>/dev/null; then
274-
echo "Certificate is PEM format (certificate only, no private key)"
275-
echo "WARNING: PEM format certificate detected but no private key available for signing"
276-
echo "Linux signing requires both certificate and private key - skipping"
277-
else
278-
echo "Unknown certificate format or corrupted certificate"
279-
echo "Certificate file info: $file_info"
280-
echo "Skipping Linux signing due to unsupported certificate format"
281-
fi
210+
# Create SHA256 checksum for integrity verification
211+
sha256sum terminusai-linux-amd64 > terminusai-linux-amd64.sha256
282212
283-
if [ "$cert_converted" = true ] && [ -f cert.pem ] && [ -f key.pem ]; then
284-
echo "Certificate converted successfully, proceeding with signing"
285-
286-
# Debug: Show certificate and key info
287-
echo "=== Certificate Info ==="
288-
openssl x509 -in cert.pem -text -noout | head -10
289-
echo "=== Key Info ==="
290-
openssl rsa -in key.pem -noout -text | head -5 2>/dev/null || echo "Key validation failed"
291-
292-
# Try different osslsigncode approaches
293-
echo "=== Attempting to sign binary ==="
294-
295-
# Method 1: Try with separate cert and key files
296-
if osslsigncode sign -certs cert.pem -key key.pem -n "TerminusAI" -i "https://github.com/${{ github.repository }}" -in terminusai-linux-amd64 -out terminusai-linux-amd64-signed 2>sign_error.log; then
297-
mv terminusai-linux-amd64-signed terminusai-linux-amd64
298-
echo "Linux binary signed successfully with separate cert/key files"
299-
else
300-
echo "Method 1 failed, trying alternative approach..."
301-
cat sign_error.log
302-
303-
# Method 2: Try combining cert and key in one file
304-
cat cert.pem key.pem > combined.pem
305-
if osslsigncode sign -certs combined.pem -key combined.pem -n "TerminusAI" -i "https://github.com/${{ github.repository }}" -in terminusai-linux-amd64 -out terminusai-linux-amd64-signed 2>sign_error2.log; then
306-
mv terminusai-linux-amd64-signed terminusai-linux-amd64
307-
echo "Linux binary signed successfully with combined cert/key file"
308-
else
309-
echo "Method 2 failed, trying PKCS#12 directly..."
310-
cat sign_error2.log
311-
312-
# Method 3: Try using PKCS#12 directly with osslsigncode
313-
if osslsigncode sign -pkcs12 certificate.bin -n "TerminusAI" -i "https://github.com/${{ github.repository }}" -in terminusai-linux-amd64 -out terminusai-linux-amd64-signed 2>sign_error3.log; then
314-
mv terminusai-linux-amd64-signed terminusai-linux-amd64
315-
echo "Linux binary signed successfully with PKCS#12 directly"
316-
else
317-
echo "All signing methods failed. Error logs:"
318-
echo "=== Final Error Log ==="
319-
cat sign_error3.log
320-
echo "Linux binary will remain unsigned"
321-
fi
322-
fi
323-
fi
324-
else
325-
echo "Certificate conversion failed - Linux binary will remain unsigned"
326-
fi
213+
# Create metadata file with build information
214+
cat > terminusai-linux-amd64.info << EOF
215+
Binary: terminusai-linux-amd64
216+
Version: ${{ github.ref_name }}
217+
Architecture: linux/amd64
218+
Build Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)
219+
Repository: ${{ github.repository }}
220+
Commit: ${{ github.sha }}
221+
EOF
327222
328-
# Clean up temporary files
329-
rm -f certificate.bin cert.pem key.pem
223+
echo "Linux binary checksum and metadata created:"
224+
cat terminusai-linux-amd64.sha256
225+
cat terminusai-linux-amd64.info
330226
331227
- name: Upload Linux Binary
332228
uses: actions/upload-artifact@v4
333229
with:
334230
name: terminusai-linux-binary
335-
path: terminusai-linux-amd64
231+
path: |
232+
terminusai-linux-amd64
233+
terminusai-linux-amd64.sha256
234+
terminusai-linux-amd64.info
336235
337236
create-release:
338237
name: Create GitHub Release
@@ -353,4 +252,6 @@ jobs:
353252
terminusai-windows-installer/terminusai-setup.exe
354253
terminusai-macos-binary/terminusai-macos-universal
355254
terminusai-linux-binary/terminusai-linux-amd64
255+
terminusai-linux-binary/terminusai-linux-amd64.sha256
256+
terminusai-linux-binary/terminusai-linux-amd64.info
356257
generate_release_notes: true

0 commit comments

Comments
 (0)