Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/hop/blob/main/tools/signing-setup.sh # hop Hop: a small native macOS launcher. Clipboard history, find, on-device dictation and your coding agent behind one key. Brought by drakestapleton Sign in to star 1 stars 1 watching About Files History Releases Proposed changes Issues For developers 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. 5 set -e 6 D="$HOME/.config/hop-signing"; KC="$HOME/Library/Keychains/hop-signing.keychain-db" 7 if [ -f "$KC" ] && [ -f "$D/keychain-password" ]; then echo "signing identity already set up"; exit 0; fi 8 mkdir -p "$D"; chmod 700 "$D"; umask 077 9 PW=$(/usr/bin/openssl rand -hex 24); printf %s "$PW" > "$D/keychain-password" 10 cat > "$D/cert.cnf" <<'CNF' 11 [req] 12 distinguished_name=dn 13 x509_extensions=v3 14 prompt=no 15 [dn] 16 CN=Hop Local Signing 17 [v3] 18 basicConstraints=critical,CA:false 19 keyUsage=critical,digitalSignature 20 extendedKeyUsage=critical,codeSigning 21 CNF 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" 25 security create-keychain -p "$PW" "$KC" 26 security set-keychain-settings "$KC" # no auto-lock timeout 27 security unlock-keychain -p "$PW" "$KC" 28 security import "$D/id.p12" -k "$KC" -P "$PW" -T /usr/bin/codesign >/dev/null 29 security set-key-partition-list -S apple-tool:,apple: -s -k "$PW" "$KC" >/dev/null 30 rm -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 33 security list-keychains -d user -s $(security list-keychains -d user | tr -d '"') "$KC" 34 echo "created signing identity 'Hop Local Signing' in $KC"