#!/bin/bash

set -e

env CA_NAME=igi_test_ca2 make_ca.sh
env CA_NAME=igi_test_ca2 make_crl.sh
install_ca.sh igi_test_ca2 trust-anchors

export CA_NAME=igi_test_ca
make_ca.sh

make_cert.sh test0
cp igi_test_ca/certs/test0.* certs

make_cert.sh star_test_example
cp igi_test_ca/certs/star_test_example.* certs

# test 1
echo | voms-proxy-init -cert certs/test0.p12 --valid 10:0 --out certs/0.pem --pwstdin
awk '/BEGIN RSA PRIVATE KEY/,/END RSA PRIVATE KEY/' certs/0.pem > certs/0.key.pem
awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' certs/0.pem > certs/0.cert.pem

# test 3
cat certs/test0.cert.pem trust-anchors/igi_test_ca.pem > certs/test0+ca.pem

make_crl.sh
install_ca.sh igi_test_ca trust-anchors
