summaryrefslogtreecommitdiff
path: root/.github/workflows/signpath-smoke.yml
blob: b6aa3a41ea0c4bdc2453706b192dda7666bf8e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: SignPath Smoke Test

# Signs a trivial PE through the full SignPath round trip (token, slugs,
# artifact configuration, trusted build system) without building or
# exposing WSJT source.

on:
  workflow_dispatch:
    inputs:
      signing-policy-slug:
        description: "SignPath signing policy to exercise"
        required: false
        type: choice
        options:
          - test-signing
          - release-signing
        default: test-signing

jobs:
  smoke:
    if: github.repository == 'WSJTX/wsjtx'
    runs-on: ubuntu-latest
    timeout-minutes: 90
    environment: windows-release-signing
    permissions:
      actions: read
      contents: read
    steps:
      - name: Build trivial PE file
        run: |
          # Keep this job independent of the dispatched repository ref. It
          # submits an executable with the SignPath API token below.
          sudo apt-get update -q
          sudo apt-get install -y -q gcc-mingw-w64-x86-64
          cat > smoke.c <<'EOF'
          #include <stdio.h>
          int main(void) { puts("WSJT SignPath smoke test"); return 0; }
          EOF
          x86_64-w64-mingw32-gcc smoke.c -o signpath-smoke.exe
          file signpath-smoke.exe

      - name: Upload unsigned artifact
        id: upload
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          name: signpath-smoke
          path: signpath-smoke.exe

      - name: Submit signing request to SignPath
        id: signpath
        uses: signpath/github-action-submit-signing-request@v3
        with:
          api-token: ${{ secrets.SIGNPATH_API_TOKEN }}
          organization-id: "4c211821-e011-48a2-8a84-2cc29a76a8bf"
          project-slug: "wsjtx"
          signing-policy-slug: ${{ inputs.signing-policy-slug }}
          github-artifact-id: ${{ steps.upload.outputs.artifact-id }}
          wait-for-completion: true
          wait-for-completion-timeout-in-seconds: "3600"
          output-artifact-directory: signed

      - name: Verify returned signature
        run: |
          echo "Signing request: ${{ steps.signpath.outputs.signing-request-web-url }}"
          sudo apt-get install -y -q osslsigncode
          ls -la signed/
          # The test cert never chains to a trusted root, so chain
          # verification can't gate here. Require instead that an
          # Authenticode signature is present and parses as PKCS#7 —
          # both commands hard-fail on an unsigned or malformed exe.
          osslsigncode extract-signature -in signed/signpath-smoke.exe -out smoke-sig.der
          openssl pkcs7 -inform DER -in smoke-sig.der -print_certs -noout
          # Chain status, informational only:
          osslsigncode verify signed/signpath-smoke.exe || true