22 lines
429 B
Bash
Executable File
22 lines
429 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
KEY_DIR="${1:-/usr/local/rustproxy-build/keys}"
|
|
KEY="$KEY_DIR/rustproxy-repo.key"
|
|
PUB="$KEY_DIR/rustproxy-repo.pub"
|
|
|
|
umask 077
|
|
mkdir -p "$KEY_DIR"
|
|
if [ -e "$KEY" ] || [ -e "$PUB" ]; then
|
|
echo "Key already exists in $KEY_DIR" >&2
|
|
exit 1
|
|
fi
|
|
|
|
openssl genrsa -out "$KEY" 2048
|
|
chmod 0400 "$KEY"
|
|
openssl rsa -in "$KEY" -out "$PUB" -pubout
|
|
chmod 0444 "$PUB"
|
|
|
|
echo "Private key: $KEY"
|
|
echo "Public key: $PUB"
|