So it turns out that one of the reasons OpenSSL was failing to connect was,
this script does not actually sign the certificate it generates with the CA
key.

This is fixed now.