fix ssl reading

Call SSL_read() until all available data have been decoded.
add certificate validation for ssl connections
fix typo in http_base64_encode_string()