Fixes a few potential segfauls and includes OpenSSL 1.1 compatibilty. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>