Crypt-SSLeay uses a number of environment variables to control its behaviour. Could it be that when run from the shell, the appropriate environment variables are set, but not when run from cron?
At the beginning of your program, add the following snippet to dump the environment table: