optimized ssl handling