add SSL read/write error checking