Fixed OpenSSL usage

Switched from deprecated OpenSSL functions to their corresponding
*_ex functions
Fixed usage of *Final functions
Switched from deprecated OpenSSL and fixed usage of *Final functions