fixed a read buffer overflow bug
updated to use the fixed ssl read functions
modularized the env var set up code for future updates