handle SSL I/O errors more gracefully, avoid double free