Improve ssl handling