#!/bin/bash

while true; do
	for cert in test-cert{1,2}.pem; do
		echo "Using certificate $cert."
		# We need to handle an HTTP request for an ics file.  Let's pass the request
		# through to mattmccutchen.net rather than reimplement an HTTP server here.
		# We don't care about the security of the connection to mattmccutchen.net for
		# this test.  Don't require a client cert either.
		# Run in the background, otherwise an interrupt doesn't seem to kill this script properly.
		socat -v OPENSSL-LISTEN:4433,key=test-key.pem,certificate=$cert,verify=0 OPENSSL:mattmccutchen.net:443,verify=0 &
		wait
	done
done
