dropped exec of openssl; uses PHP streams now;  put into function

Replaced manual exec of openssl with sed to use
PHP's SSL streams and client certificate capture
functionality. Also, put code into a function
so that it's not just a standalone script.