Skip to content

Instantly share code, notes, and snippets.

@emlun

emlun/mkcert.sh

Last active Aug 29, 2015
Embed
What would you like to do?
#!/bin/bash
FILENAME="device"
KEY_FILE="${FILENAME}.key"
REQUEST_FILE="${FILENAME}.csr"
CERT_FILE="${FILENAME}.crt"
UPLOAD_FILE="tmp/${REQUEST_FILE}"
DOWNLOAD_FILE="tmp/${CERT_FILE}"
CA_HOST=home
CA_HOST_CACERT_FILE="/etc/ssl/public/mimer-root-CA.crt"
CA_HOST_CA_KEY_FILE="/etc/ssl/private/mimer-root-CA.key"
trap 'exit $?' ERR
touch "${KEY_FILE}"
chmod 600 "${KEY_FILE}"
openssl req -newkey rsa:2048 -keyout "${KEY_FILE}" -out "${REQUEST_FILE}" -nodes
scp "${REQUEST_FILE}" "mimer:${UPLOAD_FILE}"
ssh -t "${CA_HOST}" sudo openssl x509 -req -in "'${UPLOAD_FILE}'" -CA "'${CA_HOST_CACERT_FILE}'" -CAkey "'${CA_HOST_CA_KEY_FILE}'" -out "'${DOWNLOAD_FILE}'" -days 365
scp "${CA_HOST}":"${DOWNLOAD_FILE}" "${CERT_FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.