check for ssl session before trying to allocate the buffer. Refactor allocation of buffer methods into a single method