@awakecoding do you have any opinion on this one ?
IMHO the callers should be fixed, so that if there's no remaining bytes in the stream they should not try to read a server certificate. And if so the check can be safely removed.