Initialize OpenSSL to be thread-safe, remove usage of global locks around RSA functions

Implements Redmine #2678