#!/bin/sh

set -ex

readlink() {
  (
    cd $(dirname $1)
    echo $PWD/$(basename $1)
  )
}

# Place keys and certificates here
depot_path=$(readlink ./certs)
mkdir -p ${depot_path}

ca_name="log-cache-ca"

# Install certstrap
go get -v github.com/square/certstrap

# CA to distribute to loggregator certs
certstrap --depot-path ${depot_path} init --passphrase '' --common-name $ca_name

# Log Cache certificate
certstrap --depot-path ${depot_path} request-cert --passphrase '' --common-name log-cache
certstrap --depot-path ${depot_path} sign log-cache --CA $ca_name --expires "25 years"

