typo ssl_ctx -> ctx, add null pointer check