Skip to content

Instantly share code, notes, and snippets.

@raphink
Last active May 16, 2017 12:35
Show Gist options
  • Save raphink/f76d2542d833a3ec34c602d036a5067e to your computer and use it in GitHub Desktop.
Save raphink/f76d2542d833a3ec34c602d036a5067e to your computer and use it in GitHub Desktop.
#!/bin/bash
CATTLE_CONFIG_URL_V2=${CATTLE_CONFIG_URL/v1/v2-beta}
CERT_NAME="$1"
function get_cert_val() {
local name="$1" k="$2"
curl -s -H "Authorization: ${CATTLE_AGENT_INSTANCE_AUTH}" "${CATTLE_CONFIG_URL_V2}"/certificates | \
jq -r ".data[] | select(.name == \"${name}\").${k}"
}
get_cert_val $CERT_NAME "key" > ${CERT_NAME}.key
get_cert_val $CERT_NAME "cert" > ${CERT_NAME}.crt
get_cert_val $CERT_NAME "certchain" > ${CERT_NAME}.certchain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment