interplane.Get Omega
Read in your language

hop

Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key.

Brought by drakestapleton

branch main Branches Tags History

hop / tools / signing-setup.sh

34 lines · 1810 bytes Raw Blame History
1#!/bin/sh
2# One-time: makes a local code-signing identity for Hop in its own keychain (nothing leaves this Mac).
3# With it every build has the same signature, so macOS keeps Hop's clipboard and paste permission.
4# Safe to re-run: it does nothing if the identity already exists.
5set -e
6D="$HOME/.config/hop-signing"; KC="$HOME/Library/Keychains/hop-signing.keychain-db"
7if [ -f "$KC" ] && [ -f "$D/keychain-password" ]; then echo "signing identity already set up"; exit 0; fi
8mkdir -p "$D"; chmod 700 "$D"; umask 077
9PW=$(/usr/bin/openssl rand -hex 24); printf %s "$PW" > "$D/keychain-password"
10cat > "$D/cert.cnf" <<'CNF'
11[req]
12distinguished_name=dn
13x509_extensions=v3
14prompt=no
15[dn]
16CN=Hop Local Signing
17[v3]
18basicConstraints=critical,CA:false
19keyUsage=critical,digitalSignature
20extendedKeyUsage=critical,codeSigning
21CNF
22# The system LibreSSL writes a PKCS#12 that `security import` accepts; newer OpenSSL builds do not.
23/usr/bin/openssl req -x509 -newkey rsa:2048 -nodes -keyout "$D/key.pem" -out "$D/cert.pem" -days 7300 -config "$D/cert.cnf" 2>/dev/null
24/usr/bin/openssl pkcs12 -export -inkey "$D/key.pem" -in "$D/cert.pem" -out "$D/id.p12" -passout pass:"$PW" -name "Hop Local Signing"
25security create-keychain -p "$PW" "$KC"
26security set-keychain-settings "$KC" # no auto-lock timeout
27security unlock-keychain -p "$PW" "$KC"
28security import "$D/id.p12" -k "$KC" -P "$PW" -T /usr/bin/codesign >/dev/null
29security set-key-partition-list -S apple-tool:,apple: -s -k "$PW" "$KC" >/dev/null
30rm -f "$D/key.pem" "$D/id.p12"
31# codesign only finds identities in keychains on the search list; keep every keychain already there.
32# shellcheck disable=SC2046
33security list-keychains -d user -s $(security list-keychains -d user | tr -d '"') "$KC"
34echo "created signing identity 'Hop Local Signing' in $KC"