4 # Search for all instances of OpenSSL headers and libraries
5 # and print their versions.
6 # Intended to help diagnose OpenSSH's "OpenSSL headers do not
7 # match your library" errors.
9 # Written by Darren Tucker (dtucker at zip dot com dot au)
10 # This file is placed in the public domain.
13 # 2002-07-27: Initial release.
14 # 2002-08-04: Added public domain notice.
15 # 2003-06-24: Incorporated readme, set library paths. First cvs version.
17 # "OpenSSL headers do not match your library" are usually caused by
18 # OpenSSH's configure picking up an older version of OpenSSL headers
19 # or libraries. You can use the following # procedure to help identify
22 # The output of configure will tell you the versions of the OpenSSL
23 # headers and libraries that were picked up, for example:
25 # checking OpenSSL header version... 90604f (OpenSSL 0.9.6d 9 May 2002)
26 # checking OpenSSL library version... 90602f (OpenSSL 0.9.6b [engine] 9 Jul 2001)
27 # checking whether OpenSSL's headers match the library... no
28 # configure: error: Your OpenSSL headers do not match your library
30 # Now run findssl.sh. This should identify the headers and libraries
31 # present and their versions. You should be able to identify the
32 # libraries and headers used and adjust your CFLAGS or remove incorrect
33 # versions. The output will show OpenSSL's internal version identifier
34 # and should look something like:
37 # Searching for OpenSSL header files.
38 # 0x0090604fL /usr/include/openssl/opensslv.h
39 # 0x0090604fL /usr/local/ssl/include/openssl/opensslv.h
41 # Searching for OpenSSL shared library files.
42 # 0x0090602fL /lib/libcrypto.so.0.9.6b
43 # 0x0090602fL /lib/libcrypto.so.2
44 # 0x0090581fL /usr/lib/libcrypto.so.0
45 # 0x0090602fL /usr/lib/libcrypto.so
46 # 0x0090581fL /usr/lib/libcrypto.so.0.9.5a
47 # 0x0090600fL /usr/lib/libcrypto.so.0.9.6
48 # 0x0090600fL /usr/lib/libcrypto.so.1
50 # Searching for OpenSSL static library files.
51 # 0x0090602fL /usr/lib/libcrypto.a
52 # 0x0090604fL /usr/local/ssl/lib/libcrypto.a
54 # In this example, I gave configure no extra flags, so it's picking up
55 # the OpenSSL header from /usr/include/openssl (90604f) and the library
56 # from /usr/lib/ (90602f).
59 # Adjust these to suit your compiler.
60 # You may also need to set the *LIB*PATH environment variables if
61 # DEFAULT_LIBPATH is not correct for your system.
67 # Set up conftest C source
72 int main(){printf("0x%08xL\n", SSLeay());}
76 # Set default library paths if not already set
78 DEFAULT_LIBPATH=/usr/lib:/usr/local/lib
79 LIBPATH=${LIBPATH:=$DEFAULT_LIBPATH}
80 LD_LIBRARY_PATH=${LD_LIBRARY_PATH:=$DEFAULT_LIBPATH}
81 LIBRARY_PATH=${LIBRARY_PATH:=$DEFAULT_LIBPATH}
82 export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH
85 # Search for OpenSSL headers and print versions
87 echo Searching for OpenSSL header files.
88 if [ -x "`which locate`" ]
90 headers=`locate opensslv.h`
92 headers=`find / -name opensslv.h -print 2>/dev/null`
95 for header in $headers
97 ver=`awk '/OPENSSL_VERSION_NUMBER/{printf \$3}' $header`
103 # Search for shared libraries.
104 # Relies on shared libraries looking like "libcrypto.s*"
106 echo Searching for OpenSSL shared library files.
107 if [ -x "`which locate`" ]
109 libraries=`locate libcrypto.s`
111 libraries=`find / -name 'libcrypto.s*' -print 2>/dev/null`
114 for lib in $libraries
116 (echo "Trying libcrypto $lib" >>findssl.log
118 LIBPATH="$dir:$LIBPATH"
119 LD_LIBRARY_PATH="$dir:$LIBPATH"
120 LIBRARY_PATH="$dir:$LIBPATH"
121 export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH
122 ${CC} -o conftest conftest.c $lib 2>>findssl.log
125 ver=`./conftest 2>/dev/null`
133 # Search for static OpenSSL libraries and print versions
135 echo Searching for OpenSSL static library files.
136 if [ -x "`which locate`" ]
138 libraries=`locate libcrypto.a`
140 libraries=`find / -name libcrypto.a -print 2>/dev/null`
143 for lib in $libraries
145 libdir=`dirname $lib`
146 echo "Trying libcrypto $lib" >>findssl.log
147 ${CC} ${STATIC} -o conftest conftest.c -L${libdir} -lcrypto 2>>findssl.log
150 ver=`./conftest 2>/dev/null`