diff --git a/configure.ac b/configure.ac
index bcfc780..aa0e72c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1168,11 +1168,13 @@ if test X"$OPT_SSL" != Xno; then
     dnl Try pkg-config even when cross-compiling.  Since we
     dnl specify PKG_CONFIG_LIBDIR we're only looking where
     dnl the user told us to look
-    PKGTEST="yes"
     PKG_CONFIG_LIBDIR=$OPT_SSL/lib/pkgconfig
     export PKG_CONFIG_LIBDIR
     AC_MSG_NOTICE([set PKG_CONFIG_LIBDIR to "$PKG_CONFIG_LIBDIR"])
-  
+    if test -e "$PKG_CONFIG_LIBDIR/openssl.pc"; then
+      PKGTEST="yes"
+    fi
+
     dnl in case pkg-config comes up empty, use what we got
     dnl via --with-ssl
     LIB_OPENSSL="$PREFIX_OPENSSL/lib$libsuff"
@@ -1206,12 +1208,13 @@ if test X"$OPT_SSL" != Xno; then
       dnl additional libs may be necessary.  Hope that we
       dnl don't need any.
       LIBS="$LIBS $SSL_LIBS"
-
-      dnl we're done using pkg-config for openssl
-      export PKG_CONFIG_LIBDIR="$SAVE_PKG_CONFIG_LIBDIR"
     fi
   fi
 
+  dnl we're done using pkg-config for openssl
+  PKG_CONFIG_LIBDIR="$SAVE_PKG_CONFIG_LIBDIR"
+  export PKG_CONFIG_LIBDIR
+
   dnl finally, set flags to use SSL
   CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS"
   LDFLAGS="$LDFLAGS $SSL_LDFLAGS"

