Thread safety

This changes the thread-safety earlier done to work with a single mutex.

Also fixes a problem with mal-formed certs when doing a certificate check.  Ensures that all certs will be 64 char lines.