Skip to content

How To: Code Sign Protected Apps

PyLocket does not code-sign your app. You sign the protected build with your own certificate (on macOS you also notarize it) and upload the signed copy back to PyLocket, which then delivers that copy to your customers. This page shows how.

An app you have not signed meets a Windows SmartScreen warning or a macOS Gatekeeper block when your customers open it, and the PyLocket Installer and Hub refuse to install it on those platforms.


Why Code Signing Matters

macOS — Gatekeeper

Unsigned apps trigger: "MyApp can't be opened because Apple cannot check it for malicious software." On macOS 15 and later, users must open System Settings → Privacy & Security and click Open Anyway for your app (the older right-click → Open shortcut no longer bypasses Gatekeeper). For professional distribution, you need:

  • Apple Developer ID certificate ($99/year via developer.apple.com)
  • Notarization — Apple scans your app and issues a ticket that Gatekeeper accepts

Windows — SmartScreen

Unsigned executables trigger: "Windows protected your PC — Microsoft Defender SmartScreen prevented an unrecognized app from starting." For trusted distribution, you need:

  • Code signing certificate from a trusted CA (DigiCert, Sectigo, GlobalSign)
  • An EV (Extended Validation) or a standard certificate. Since 2024 neither gives a new release immediate SmartScreen trust: SmartScreen shows its prompt until the file has built up download reputation, whatever the certificate type. Signing still names you as the publisher in that prompt

How PyLocket Affects Signatures

PyLocket protection modifies your artifact: it adds the encrypted payload, runtime binary, and bootstrap loader. This invalidates any existing code signature, so you re-sign the protected output with your own certificate before distribution.

Sign your own files, never PyLocket's

PyLocket adds two runtime files to your app: its runtime library, _pylocket_rt (_pylocket_rt.so on macOS, _pylocket_rt.pyd on Windows), and its license prompt, _pylocket_prompt (_pylocket_prompt.exe on Windows). On Windows and macOS each of these files is individually code-signed by Lamaute Labs, the company behind PyLocket. That signature covers those two files only, never your app.

  • Sign everything else with your own certificate: your executable, your libraries and, on macOS, the app bundle itself. On macOS you also notarize the app.
  • Leave PyLocket's files as they are. Do not re-sign them. Their Lamaute Labs signature is what lets antivirus vendors recognize them as PyLocket's runtime, the same files in every protected app, rather than as unknown code in yours. Re-signing them replaces that signature and changes the files.
  • In practice, sign every file that is not already validly signed. On macOS, that is every nested Mach-O file that does not already carry a valid Developer ID signature (codesign -dv shows an Authority=Developer ID Application line and a TeamIdentifier), signed inside-out, and then the bundle, without --deep. On Windows, it is every .exe, .dll and .pyd file whose Authenticode signature does not already verify. Never re-sign a file that already verifies. The examples below do exactly this.

What this means on each platform

  • macOS .app bundles: PyLocket produces a protected .app laid out so you can sign and notarize it with your own Apple Developer ID. Top-level code (Mach-O files, .dylib and .so files, *.framework bundles) stays in Contents/Frameworks/; your Python packages, including the .so files inside them, are in Contents/Resources/. Sign it inside-out: the nested binaries first, then the bundle. Do not sign with codesign --deep: it re-signs every nested file with your identity, PyLocket's included, and it does not descend into Contents/Resources/, so it leaves those binaries without your signature and notarization rejects them. The macOS example below signs inside-out. PyLocket applies only an ad-hoc signature (no identity) so the protected .app launches on Apple Silicon; it does not sign it with a Developer ID or notarize it for you.
  • macOS runtime library and library validation: PyLocket's runtime library (_pylocket_rt.so) is Developer-ID-signed by Lamaute Labs, not by you. Under the hardened runtime, library validation refuses to load a library signed by a different Team. When you sign your protected app under the hardened runtime, always add the com.apple.security.cs.disable-library-validation entitlement (the macOS example below does), or the app crashes on its first protected call.
  • Windows .exe: PyLocket does not re-sign; the protected .exe will trigger SmartScreen until you sign it. A single-file .exe carries PyLocket's runtime files inside it, so signing the .exe is all you do. A folder build has them as separate files next to yours (below).
  • In both cases: sign the protected artifact with your own certificate, then upload the signed copy to PyLocket (below) so that is what your customers download.

End-to-End Pipeline

flowchart LR
    A["1. BUILD\n(your CI)"] --> B["2. PROTECT\n(PyLocket)"]
    B --> C["3. WEBHOOK\n(event)"]
    C --> D["4. DOWNLOAD\n+ 5. SIGN"]
    D --> E["6. DISTRIB\n(upload)"]
    E --> F["7. END USER\nruns app"]
  1. Your build pipeline creates the app (PyInstaller, cx_Freeze, Briefcase, etc.)
  2. Submit to PyLocket for protection: pylocket protect --no-wait
  3. PyLocket sends a webhook event when protection completes
  4. Your pipeline downloads the protected artifact
  5. Your pipeline signs it with your certificate (and notarizes it on macOS)
  6. Upload the signed artifact for distribution: back to PyLocket with Replace with Signed Package, or to your own website or store
  7. End users download and run the protected app with your signature

Configure Webhooks

Instead of polling for build completion (which doesn't scale for long queues), configure a webhook to be notified instantly:

# Set up a webhook URL for your app
pylocket webhook set --app <APP_ID> --url https://your-server.com/pylocket-webhook

# The command returns a secret — save it immediately!
# Secret: pyls_abc123...

# Test the webhook
pylocket webhook test --app <APP_ID>

# Check delivery history
pylocket webhook status --app <APP_ID>

Webhook Payload

When a build completes, PyLocket POSTs a JSON payload:

{
  "event": "build.completed",
  "timestamp": "2026-04-04T12:00:00Z",
  "build": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "app_id": "3f8a1c22-9b4e-4d17-a6f0-2c5e7d90b114",
    "version": "2.1.0",
    "status": "ready",
    "platform": "darwin-arm64",
    "protected_size_bytes": 52974581,
    "download_path": "/v1/builds/550e8400-e29b-41d4-a716-446655440000/download"
  }
}

The fields you need to react to a completed build are id, status, and download_path (fetch the protected artifact from that path). Additional metadata fields may be present in the payload; treat the schema as additive and ignore fields you don't use.

Verify Webhook Signatures

Every webhook includes an X-PyLocket-Signature header:

X-PyLocket-Signature: t=1712188800,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8f9

Verify it in your receiver:

import hmac, hashlib, json

def verify_signature(payload_body: bytes, signature_header: str, secret: str) -> bool:
    parts = dict(p.split("=", 1) for p in signature_header.split(","))
    timestamp = parts["t"]
    expected = parts["v1"]
    signed_content = f"{timestamp}.{payload_body.decode()}"
    computed = hmac.new(secret.encode(), signed_content.encode(), hashlib.sha256).hexdigest()
    return hmac.compare_digest(computed, expected)

macOS: Sign with Apple Developer ID

Prerequisites

  • Apple Developer account ($99/year)
  • Developer ID Application certificate installed in Keychain
  • Xcode command-line tools (xcode-select --install)

What you sign: the protected .app from engine 181

PyLocket returns a macOS app as a .app.zip. Engine 181 changed how PyLocket handles duplicate library copies and execute permissions in it. A build protected on an earlier engine keeps what it had; protect a new build to get these changes.

  • One more kind of duplicate library copy becomes a link again. PyInstaller 6 builds a .app with symbolic links between Contents/Frameworks/ and Contents/Resources/. An upload that lost those links (copied with rsync -aL or cp -L, or zipped with zip -r without -y) has a second, real copy of each linked file instead. Earlier engines already made the Resources/ copy a link again when both copies were real and identical (and for a duplicate .framework). Engine 181 adds the case of a code file directly under Contents/Resources/ (for example Python or a lib*.dylib) whose Contents/Frameworks/ entry is a link, or is made one during protection (as Contents/Frameworks/Python is, into Python.framework), and leads to a file with exactly the same bytes: PyLocket now makes the Resources/ copy a link too, so the bundle holds one real copy of that library. A copy whose bytes differ is left as it is. Engine 180 and earlier left the second real copy in that case.
  • Execute permissions also follow the content. In the .app.zip, in addition to what earlier engines marked executable (every file in Contents/MacOS/, .so and .dylib files, and PyLocket's _pylocket_prompt helper), a file is now executable when it is Mach-O code, such as Contents/Frameworks/Python.framework/Versions/3.13/Python, which has no extension, or when it was executable in your upload. Every other file is 0644 (readable, not executable), and setuid, setgid and sticky bits are never kept. unzip and ditto -x -k both keep these permissions when you extract the archive.

The simplest upload keeps the links in the first place: pylocket protect --app <APP_ID> --artifact dist/MyApp.app archives the bundle with its links and permissions, and for an upload in the portal ditto -c -k --keepParent dist/MyApp.app dist/MyApp.app.zip does the same.

GitHub Actions Example

name: Build, Protect, Sign (macOS)

on:
  push:
    tags: ['v*']

jobs:
  build-protect-sign:
    runs-on: macos-14
    steps:
      - uses: actions/checkout@v4

      - name: Build app
        run: |
          pip install pyinstaller
          # A macOS .app must be built with --onedir (PyLocket refuses a
          # --onefile .app)
          pyinstaller --onedir --windowed --name MyApp src/main.py

      - name: Protect with PyLocket
        env:
          PYLOCKET_TOKEN: ${{ secrets.PYLOCKET_TOKEN }}
        run: |
          pip install pylocket
          # protect waits for completion by default; --out downloads the
          # protected artifact when the build is ready
          pylocket protect \
            --app ${{ secrets.PYLOCKET_APP_ID }} \
            --artifact dist/MyApp.app \
            --platform macos-arm64 \
            --out dist/protected/

      - name: Sign with Developer ID
        env:
          CERT_NAME: "Developer ID Application: Your Name (TEAMID)"
        run: |
          set -euo pipefail

          # Unzip the protected .app
          cd dist/protected && unzip -q *.app.zip
          APP=MyApp.app

          # Entitlements. PyLocket's runtime library (_pylocket_rt.so) is
          # signed by Lamaute Labs, not by you. Under the hardened runtime,
          # library validation refuses a library from another Team unless the app
          # has disable-library-validation, so always keep this entitlement.
          # Without it, the app crashes on first use.
          cat > entitlements.plist <<'EOF'
          <?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
          <plist version="1.0">
          <dict>
            <key>com.apple.security.cs.disable-library-validation</key>
            <true/>
          </dict>
          </plist>
          EOF

          # Sign inside-out under the hardened runtime: nested code first, then
          # the bundle. A file that already carries a valid Developer ID
          # signature is left exactly as it is. PyLocket's runtime files
          # (_pylocket_rt.so and _pylocket_prompt) are signed by Lamaute Labs,
          # and some third-party libraries are signed by their vendors. Your
          # signature goes on everything else.

          # Valid, Developer ID Application, a Team ID and a secure timestamp
          # (plus the hardened runtime for an executable): what notarization
          # needs from a nested file.
          has_developer_id() {
            codesign --verify --strict --all-architectures "$1" 2>/dev/null || return 1
            info="$(codesign -dv --verbose=4 "$1" 2>&1)" || return 1
            case "$info" in *"Authority=Developer ID Application: "*) ;; *) return 1 ;; esac
            case "$info" in *"TeamIdentifier=not set"*) return 1 ;; *"TeamIdentifier="*) ;; *) return 1 ;; esac
            case "$info" in *"Timestamp="*) ;; *) return 1 ;; esac
            case "$(file -b "$1")" in
              *executable*) case "$info" in *"runtime)"*|*"runtime,"*) ;; *) return 1 ;; esac ;;
            esac
          }

          # Every Mach-O file in the bundle, deepest first, except the main
          # executable (step 3 signs it, with the entitlements). Symbolic links
          # are skipped: signing the file a link points to covers it.
          MAIN="$APP/Contents/MacOS/$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$APP/Contents/Info.plist")"
          nested_code() {
            find "$APP/Contents" -type f ! -path "$MAIN" -print0 |
              while IFS= read -r -d '' f; do
                case "$(file -b "$f")" in
                  *Mach-O*executable*|*Mach-O*"shared library"*|*Mach-O*bundle*) printf '%s\n' "$f" ;;
                esac
              done | awk '{ print gsub("/", "/"), $0 }' | sort -rn | cut -d' ' -f2-
          }

          # 0. Check that this is the protected app: it contains PyLocket's
          #    runtime files.
          if [ -z "$(find "$APP" -type f -name '_pylocket_rt*.so' -print)" ] ||
             [ -z "$(find "$APP" -type f -name '_pylocket_prompt' -print)" ]; then
            echo "PyLocket's runtime files are not in $APP: sign the protected .app" >&2
            exit 1
          fi

          # 1. Nested Mach-O files. kept.sha256 lists the files left as they
          #    were, for the check after signing.
          : > kept.sha256
          nested_code | while IFS= read -r f; do
            if has_developer_id "$f"; then
              shasum -a 256 "$f" >> kept.sha256
            else
              codesign --force --options runtime --timestamp --sign "$CERT_NAME" "$f"
            fi
          done

          # 2. Nested bundles (frameworks such as Python.framework, helper
          #    apps), deepest first, unless they already verify as above.
          find "$APP/Contents" -type d \( -name '*.framework' -o -name '*.app' \) -print |
            awk '{ print gsub("/", "/"), $0 }' | sort -rn | cut -d' ' -f2- |
            while IFS= read -r b; do
              has_developer_id "$b" ||
                codesign --force --options runtime --timestamp --sign "$CERT_NAME" "$b"
            done

          # 3. The app bundle itself: the entitlements go here only, and no
          #    --deep (it would re-sign every nested file with your identity,
          #    PyLocket's included).
          codesign --force --options runtime --timestamp \
            --entitlements entitlements.plist \
            --sign "$CERT_NAME" "$APP"

          # If codesign stops with "too many levels of symbolic links", the bundle
          # has a symbolic-link loop and the files behind it are missing. A build
          # protected by an engine older than 1.0.0.0.0.180 can have one in a
          # package that mixes code and data: upload your app again so the
          # current engine protects it. Never delete the symlinks or the
          # *.dist-info folders to get past an error: they are load-bearing
          # (plugin loaders register through them) and PyLocket rejects a
          # signed re-upload that lost them.

          # Verify the signature (Gatekeeper's spctl check comes after
          # notarization, below)
          codesign --verify --deep --strict --verbose=2 "$APP"

          # The entitlement is on the app: the output lists
          # com.apple.security.cs.disable-library-validation
          codesign -d --entitlements - "$APP"

          # The files you left as they were are unchanged, byte for byte
          [ ! -s kept.sha256 ] || shasum -a 256 -c kept.sha256

          # Every nested Mach-O file now has a Developer ID signature, as
          # notarization requires (this prints nothing when they all do)
          unsigned="$(nested_code | while IFS= read -r f; do has_developer_id "$f" || printf '%s\n' "$f"; done)"
          if [ -n "$unsigned" ]; then
            printf 'No valid Developer ID signature:\n%s\n' "$unsigned" >&2
            exit 1
          fi

          # Confirm your signing step preserved the package metadata (must list
          # the same paths as before signing; empty output here means a tool
          # stripped them and the re-upload will be rejected)
          find MyApp.app -name entry_points.txt

      - name: Notarize
        env:
          APPLE_ID: ${{ secrets.APPLE_ID }}
          APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
          TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
        run: |
          # Create ZIP for notarization
          ditto -c -k --keepParent dist/protected/MyApp.app MyApp.app.zip

          # Submit and wait
          xcrun notarytool submit MyApp.app.zip \
            --apple-id "$APPLE_ID" \
            --password "$APP_PASSWORD" \
            --team-id "$TEAM_ID" \
            --wait

          # Staple the ticket
          xcrun stapler staple dist/protected/MyApp.app

          # Gatekeeper accepts the app once it is notarized and stapled
          spctl --assess --type exec dist/protected/MyApp.app

Check PyLocket's files after signing

codesign -dv names who signed a file:

codesign -dv --verbose=4 MyApp.app/Contents/Frameworks/_pylocket_rt.so 2>&1 | grep -E '^(Authority|TeamIdentifier|Timestamp)='
codesign -dv --verbose=4 MyApp.app 2>&1 | grep -E '^(Authority|TeamIdentifier)='

PyLocket's runtime library still shows Authority=Developer ID Application: Lamaute Labs LLC (7M467D3H2A) and TeamIdentifier=7M467D3H2A, and the app shows your name and your Team ID. If the runtime library shows your Team ID, your signing step re-signed it (usually codesign --deep): start again from the protected build and use the script above. In a Briefcase app, PyLocket's files are under Contents/Resources/app/; find MyApp.app -name '_pylocket_*' lists them.

A single executable instead of a .app

If your macOS build is a single executable (PyInstaller --onefile without --windowed) rather than a .app, PyLocket's runtime files are packed inside it and keep their Lamaute Labs signature when it unpacks them, so sign just that one file, with the same entitlements: codesign --force --options runtime --timestamp --entitlements entitlements.plist --sign "$CERT_NAME" myapp. Notarize it inside a zip (ditto -c -k myapp myapp.zip, then xcrun notarytool submit). A bare executable cannot be stapled, so Gatekeeper checks its notarization online.


Windows: Sign with Authenticode

Prerequisites

  • Code signing certificate (.pfx file) from a trusted CA
  • Windows SDK (signtool.exe)

GitHub Actions Example

name: Build, Protect, Sign (Windows)

on:
  push:
    tags: ['v*']

jobs:
  build-protect-sign:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4

      - name: Build exe
        run: |
          pip install pyinstaller
          pyinstaller --onefile --name MyApp src/main.py

      - name: Protect with PyLocket
        env:
          PYLOCKET_TOKEN: ${{ secrets.PYLOCKET_TOKEN }}
        run: |
          pip install pylocket
          # protect waits for completion by default; --out downloads the
          # protected artifact when the build is ready
          pylocket protect `
            --app ${{ secrets.PYLOCKET_APP_ID }} `
            --artifact dist/MyApp.exe `
            --platform win-x64 `
            --out dist/protected/

      - name: Sign with Authenticode
        env:
          CERT_PASSWORD: ${{ secrets.CODE_SIGNING_PASSWORD }}
        run: |
          # Decode certificate from base64 secret
          $certBytes = [Convert]::FromBase64String("${{ secrets.CODE_SIGNING_CERT_B64 }}")
          [IO.File]::WriteAllBytes("cert.pfx", $certBytes)

          # Sign with SHA-256 + timestamp. PyLocket's runtime files are inside
          # MyApp.exe with their own Lamaute Labs signature, so signing the
          # .exe is all you do.
          & "C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe" sign `
            /f cert.pfx /p "$env:CERT_PASSWORD" `
            /tr http://timestamp.digicert.com /td sha256 /fd sha256 `
            dist/protected/MyApp.exe

          # Verify
          & "C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe" verify `
            /pa dist/protected/MyApp.exe

          # Clean up
          Remove-Item cert.pfx

A folder build (PyInstaller onedir, cx_Freeze, Briefcase)

A folder build has PyLocket's runtime files next to yours: in _internal\ for PyInstaller onedir, in lib\ for cx_Freeze, and in the app folder for Briefcase. Sign every .exe, .dll and .pyd file whose signature does not already verify. That leaves _pylocket_rt.pyd and _pylocket_prompt.exe with their Lamaute Labs signature, and any other vendor's signed DLL (Briefcase's python3XX.dll, for example) with its own:

$signtool = "C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe"
$dir = "dist\protected\MyApp"   # the protected folder, extracted

Get-ChildItem $dir -Recurse -File -Include *.exe,*.dll,*.pyd |
  Where-Object { (Get-AuthenticodeSignature $_.FullName).Status -ne 'Valid' } |
  ForEach-Object {
    & $signtool sign /f cert.pfx /p "$env:CERT_PASSWORD" `
      /tr http://timestamp.digicert.com /td sha256 /fd sha256 $_.FullName
    if ($LASTEXITCODE -ne 0) { throw "signtool failed on $($_.FullName)" }
  }

Replace with Signed Package does not take a folder build yet, so you distribute the signed folder yourself.

Check the signatures

Get-ChildItem $dir -Recurse -File -Include *.exe,*.dll,*.pyd |
  Get-AuthenticodeSignature |
  Format-Table Status, @{ n = 'Signer'; e = { $_.SignerCertificate.Subject } }, Path -AutoSize

Every file shows Valid. _pylocket_rt.pyd and _pylocket_prompt.exe name Lamaute Labs LLC as the signer, and your files name you. signtool verify /pa /v <file> shows the same for one file. For a single-file .exe, run the same check on $env:TEMP\_MEI*\ while the app is running: PyLocket's files are unpacked there with their Lamaute Labs signature.


Certificate Types Reference

Platform Certificate Typical Cost Trust Level
macOS Apple Developer ID $99/year Trusted after notarization
Windows Standard code signing $200-400/year Builds SmartScreen reputation over time
Windows EV code signing (HSM) $400-700/year Builds SmartScreen reputation over time (no longer immediate)

Upload the Signed App Back to PyLocket

After signing, replace the protected artifact in PyLocket with your signed copy. PyLocket stores it byte for byte, so your signature (and your notarization, if you notarized it) stays intact, and downloads, push updates and the PyLocket Installer and Hub deliver your signed app. Until you do, downloads and push updates deliver the protected build without your signature, and the Installer and Hub refuse it on Windows and macOS. The build must be ready. You can also do this in the Developer Portal; see Replace with Signed Package.

Replace with Signed Package takes a macOS .app (including Briefcase) or a single-file Windows .exe. A Windows build uploaded as a folder (PyInstaller onedir, cx_Freeze) cannot be replaced with a signed copy yet, so the PyLocket Installer and Hub cannot install it.

In the default delivery mode, each newly protected build is served as soon as it is ready, before you have signed it, and it takes over from the signed copy of the previous build. To serve only signed copies, switch the app to serve released builds only and release each build after you upload its signed copy (see If your app serves only released builds).

The simplest way to upload is the CLI, which runs all three steps below and archives a .app with its symlinks for you:

pylocket replace-signed <BUILD_ID> <SIGNED_PATH>

To call the API directly, save these steps as a script and run it with bash (not pasted into a terminal: set -euo pipefail stops the script at the first failed step, so step 3 never re-checks an older upload, but it would also close an interactive shell). The script reads TOKEN (your access token), APP_ID and BUILD_ID from its environment, so export them first:

export TOKEN=<ACCESS_TOKEN> APP_ID=<APP_ID> BUILD_ID=<BUILD_ID>
set -euo pipefail

# The signed file: the signed .exe, or for macOS the signed .app archived with
#   ditto -c -k --keepParent MyApp.app MyApp.app.zip
SIGNED=dist/protected/MyApp.exe
SIZE=$(wc -c < "$SIGNED" | tr -d ' ')
SHA256=$(shasum -a 256 "$SIGNED" | cut -d ' ' -f 1)   # or: sha256sum

# 1. Get a presigned upload URL. The body gives the file's size in bytes and
#    its SHA-256 (64 hex characters); both fields are required. If the request
#    is refused (for example, the build is not ready), jq stops and prints
#    the response, whose "error" says why.
UPLOAD_URL=$(curl -sS -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"file_size_bytes\": $SIZE, \"file_hash_sha256\": \"$SHA256\"}" \
  https://api.pylocket.com/v1/apps/$APP_ID/builds/$BUILD_ID/replace \
  | jq -r '.upload_url // error("no upload URL: \(.)")')

# 2. Upload the signed file. The URL is signed for this Content-Type, so send
#    exactly this header. -f makes curl fail on an HTTP error; -S prints it.
curl -sSf -X PUT -H "Content-Type: application/octet-stream" \
  --upload-file "$SIGNED" "$UPLOAD_URL"

# 3. Confirm. PyLocket checks that the upload is a signed copy of this
#    protected build. This prints the response and then its HTTP status.
curl -sS -X POST -w '\nHTTP status: %{http_code}\n' \
  -H "Authorization: Bearer $TOKEN" \
  https://api.pylocket.com/v1/apps/$APP_ID/builds/$BUILD_ID/replace/confirm

Read success in the confirm's response, not only the HTTP status. When PyLocket refuses the uploaded file, the answer is HTTP 200 with "success": false. The one exception is a file that VirusTotal already knows as malicious, which gets 403.

Confirm response What it means
200, "success": true The build's protected artifact is now your signed file. message notes it if the download cache could not be refreshed.
200, "success": false The file was refused and nothing was replaced. message says what to fix: for example, the upload is not a zip, its symlinks were flattened, it is not signed, or it is not a signed copy of this build. Fix the file and run all three steps again.
400 This build's type can't be replaced.
403 VirusTotal already knows the signed file as malicious, and nothing was replaced. A suspended account also gets 403.
404 The app, the build or the uploaded file wasn't found. Run step 2 before step 3.
409 The build isn't ready.

An error status comes with a JSON body whose error.message says why.


Troubleshooting

macOS

Issue Solution
"unidentified developer" Sign with Developer ID and notarize
"damaged and can't be opened" Run xattr -cr MyApp.app then re-sign
Notarization fails Check xcrun notarytool log <submission-id> for details
spctl rejects after signing Ensure --options runtime flag was used
The app fails on its first protected call, and the error or the system log mentions "different Team IDs" The app was signed without the com.apple.security.cs.disable-library-validation entitlement, so library validation refused PyLocket's runtime library. Sign the bundle with --entitlements entitlements.plist (step 3 of the script) and check with codesign -d --entitlements - MyApp.app
codesign -dv shows your Team ID on _pylocket_rt.so Your signing step re-signed PyLocket's runtime files, usually with codesign --deep. Start again from the protected build and sign with the script above, which leaves files that already carry a valid Developer ID signature as they are

Windows

Issue Solution
SmartScreen warning persists Expected for a new release, with an EV or a standard certificate: the prompt goes away once the file has built up download reputation. Check that the prompt names you as the publisher
"Signature not valid" Ensure timestamp server was specified (/tr)
_pylocket_rt.pyd or _pylocket_prompt.exe names you as the signer Your signing step re-signed PyLocket's runtime files. Start again from the protected build and sign only files whose signature does not already verify (folder build)
signtool not found Install Windows SDK or use dotnet tool install sign
Certificate expired Timestamped signatures remain valid indefinitely