Provide openssl with a locking callback using Semaphores.

In order to be thread safe, openssl needs to be provided with a
callback that it will call to doing locking around its data
structures. Doing this should mean a lot fewer random crashes.