refactor travis custom openssl code to work with other versions
diff --git a/.travis/install.sh b/.travis/install.sh
index 0e5cdb4..f04c2ff 100755
--- a/.travis/install.sh
+++ b/.travis/install.sh
@@ -62,26 +62,22 @@
         pyenv global pypy-4.0.1
     fi
     if [[ "${OPENSSL}" == "0.9.8" ]]; then
-      # download, compile, and install if it's not already present via travis cache
-      # This is 0.9.8l rather than zh because we have some branches for handling
-      # < 0.9.8m that won't be exercised with a newer OpenSSL. (RHEL5 is 0.9.8e with
-      # patches, but while that's in jenkins we don't get coverage data from it)
-      if [[ ! -f "$HOME/ossl-098l/bin/openssl" ]]; then
-        curl -O https://www.openssl.org/source/openssl-0.9.8l.tar.gz
-        tar zxf openssl-0.9.8l.tar.gz
-        cd openssl-0.9.8l
-        echo "OPENSSL_0.9.8L_CUSTOM {
-            global:
-              *;
-        };" > openssl.ld
-        ./config no-asm no-ssl2 -Wl,--version-script=openssl.ld -Wl,-Bsymbolic-functions -fPIC shared --prefix=$HOME/ossl-098l
-        make depend
-        make install
-      fi
-      export PATH="$HOME/ossl-098l/bin:$PATH"
-      export CFLAGS="-I$HOME/ossl-098l/include"
-      export LDFLAGS="-L$HOME/ossl-098l/lib"
-      export LD_LIBRARY_PATH="$HOME/ossl-098l/lib"
+        # We use 0.9.8l rather than zh because we have some branches for handling
+        # < 0.9.8m that won't be exercised with a newer OpenSSL. (RHEL5 is 0.9.8e with
+        # patches, but while that's in jenkins we don't get coverage data from it).
+        OPENSSL_VERSION_NUMBER="0.9.8l"
+        OPENSSL_DIR="ossl-098l"
+    fi
+    # download, compile, and install if it's not already present via travis cache
+    if [ ! -z "$OPENSSL_DIR" ]; then
+        if [[ ! -f "$HOME/$OPENSSL_DIR/bin/openssl" ]]; then
+            curl -O https://www.openssl.org/source/openssl-$OPENSSL_VERSION_NUMBER.tar.gz
+            tar zxf openssl-$OPENSSL_VERSION_NUMBER.tar.gz
+            cd openssl-$OPENSSL_VERSION_NUMBER
+            ./config shared no-asm no-ssl2 -fPIC --prefix=$HOME/$OPENSSL_DIR
+            make depend
+            make install
+        fi
     fi
     pip install virtualenv
 fi
diff --git a/.travis/run.sh b/.travis/run.sh
index 23b9e89..c8707a4 100755
--- a/.travis/run.sh
+++ b/.travis/run.sh
@@ -24,10 +24,14 @@
         eval "$(pyenv init -)"
     fi
     if [[ "${OPENSSL}" == "0.9.8" ]]; then
-      export PATH="$HOME/ossl-098l/bin:$PATH"
-      export CFLAGS="-I$HOME/ossl-098l/include"
-      export LDFLAGS="-L$HOME/ossl-098l/lib"
-      export LD_LIBRARY_PATH="$HOME/ossl-098l/lib"
+        OPENSSL_DIR="ossl-098l"
+    fi
+
+    if [ ! -z "$OPENSSL_DIR" ]; then
+        export PATH="$HOME/$OPENSSL_DIR/bin:$PATH"
+        export CFLAGS="-I$HOME/$OPENSSL_DIR/include"
+        # rpath on linux will cause it to use an absolute path so we don't need to do LD_LIBRARY_PATH
+        export LDFLAGS="-L$HOME/$OPENSSL_DIR/lib -Wl,-rpath=$HOME/$OPENSSL_DIR/lib"
     fi
 fi
 source ~/.venv/bin/activate