Detect EOF while reading in libssl