#!/bin/bash
# Generate truststore.p12 and sync everything to S3
rm -f truststore.p12
for i in client_cert.pem root_cert.pem; do
	CERT=$(echo $i | sed 's/_cert.pem//')
	keytool -importcert -storetype PKCS12 -keystore truststore.p12 -alias $CERT -storepass uselesspw -file ${CERT}_cert.pem -noprompt
done

aws s3 cp client.p12 s3://tcc-client-auth/branches/client.p12
aws s3 cp other.p12 s3://tcc-client-auth/branches/other.p12

aws s3 cp service.p12 s3://tcc-client-auth/keystore/keystore.p12
aws s3 cp truststore.p12 s3://tcc-client-auth/truststore/truststore.p12
aws s3 cp crl s3://tcc-client-auth/crl/crl.txt
