$NetBSD: patch-bl,v 1.1 2006/10/19 11:51:27 markd Exp $

--- source/libs/comm/cl_ssl_framework.c.orig	2006-10-08 23:52:33.000000000 +1300
+++ source/libs/comm/cl_ssl_framework.c
@@ -988,6 +988,9 @@ static int cl_com_ssl_build_symbol_table
    {
       char* func_name = NULL;
       int had_errors = 0;
+#if defined(FREEBSD) || defined(NETBSD)
+      void* cl_com_ssl_crypto_handle_saved = NULL;
+#endif
 
 
       CL_LOG(CL_LOG_INFO,"loading ssl library functions with dlopen() ...");
@@ -1002,9 +1005,16 @@ static int cl_com_ssl_build_symbol_table
 
 #if defined(DARWIN)
 #ifdef RTLD_NODELETE
-      cl_com_ssl_crypto_handle = dlopen ("libssl.bundle", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
+      cl_com_ssl_crypto_handle = dlopen ("libssl.dylib", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
+#else
+      cl_com_ssl_crypto_handle = dlopen ("libssl.dylib", RTLD_NOW | RTLD_GLOBAL );
+#endif /* RTLD_NODELETE */
+
+#elif defined(FREEBSD) || defined(NETBSD)
+#ifdef RTLD_NODELETE
+      cl_com_ssl_crypto_handle = dlopen ("libssl.so", RTLD_LAZY | RTLD_GLOBAL | RTLD_NODELETE);
 #else
-      cl_com_ssl_crypto_handle = dlopen ("libssl.bundle", RTLD_NOW | RTLD_GLOBAL );
+      cl_com_ssl_crypto_handle = dlopen ("libssl.so", RTLD_LAZY | RTLD_GLOBAL);
 #endif /* RTLD_NODELETE */
 
 #elif defined(HP11)
@@ -1029,6 +1039,10 @@ static int cl_com_ssl_build_symbol_table
          return CL_RETVAL_SSL_DLOPEN_SSL_LIB_FAILED;
       }
       
+#if defined(FREEBSD) || defined(NETBSD)
+      cl_com_ssl_crypto_handle_saved = cl_com_ssl_crypto_handle;
+      cl_com_ssl_crypto_handle = RTLD_DEFAULT;
+#endif
 
 
       /* setting up crypto function pointers */
@@ -1649,6 +1663,10 @@ static int cl_com_ssl_build_symbol_table
          return CL_RETVAL_SSL_CANT_LOAD_ALL_FUNCTIONS;
       }
 
+#if defined(FREEBSD) || defined(NETBSD)
+      cl_com_ssl_crypto_handle = cl_com_ssl_crypto_handle_saved;
+#endif
+
       pthread_mutex_unlock(&cl_com_ssl_crypto_handle_mutex);
       CL_LOG(CL_LOG_INFO,"loading ssl library functions with dlopen() done");
 
