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.
16 # 2004-12-13: Add traps to cleanup temp files, from Amarendra Godbole.
18 # "OpenSSL headers do not match your library" are usually caused by
19 # OpenSSH's configure picking up an older version of OpenSSL headers
20 # or libraries. You can use the following # procedure to help identify
23 # The output of configure will tell you the versions of the OpenSSL
24 # headers and libraries that were picked up, for example:
26 # checking OpenSSL header version... 90604f (OpenSSL 0.9.6d 9 May 2002)
27 # checking OpenSSL library version... 90602f (OpenSSL 0.9.6b [engine] 9 Jul 2001)
28 # checking whether OpenSSL's headers match the library... no
29 # configure: error: Your OpenSSL headers do not match your library
31 # Now run findssl.sh. This should identify the headers and libraries
32 # present and their versions. You should be able to identify the
33 # libraries and headers used and adjust your CFLAGS or remove incorrect
34 # versions. The output will show OpenSSL's internal version identifier
35 # and should look something like:
38 # Searching for OpenSSL header files.
39 # 0x0090604fL /usr/include/openssl/opensslv.h
40 # 0x0090604fL /usr/local/ssl/include/openssl/opensslv.h
42 # Searching for OpenSSL shared library files.
43 # 0x0090602fL /lib/libcrypto.so.0.9.6b
44 # 0x0090602fL /lib/libcrypto.so.2
45 # 0x0090581fL /usr/lib/libcrypto.so.0
46 # 0x0090602fL /usr/lib/libcrypto.so
47 # 0x0090581fL /usr/lib/libcrypto.so.0.9.5a
48 # 0x0090600fL /usr/lib/libcrypto.so.0.9.6
49 # 0x0090600fL /usr/lib/libcrypto.so.1
51 # Searching for OpenSSL static library files.
52 # 0x0090602fL /usr/lib/libcrypto.a
53 # 0x0090604fL /usr/local/ssl/lib/libcrypto.a
55 # In this example, I gave configure no extra flags, so it's picking up
56 # the OpenSSL header from /usr/include/openssl (90604f) and the library
57 # from /usr/lib/ (90602f).
60 # Adjust these to suit your compiler.
61 # You may also need to set the *LIB*PATH environment variables if
62 # DEFAULT_LIBPATH is not correct for your system.
68 # Cleanup on interrupt
70 trap 'rm -f conftest.c' INT HUP TERM
73 # Set up conftest C source
78 int main(){printf("0x%08xL\n", SSLeay());}
82 # Set default library paths if not already set
84 DEFAULT_LIBPATH=/usr/lib:/usr/local/lib
85 LIBPATH=${LIBPATH:=$DEFAULT_LIBPATH}
86 LD_LIBRARY_PATH=${LD_LIBRARY_PATH:=$DEFAULT_LIBPATH}
87 LIBRARY_PATH=${LIBRARY_PATH:=$DEFAULT_LIBPATH}
88 export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH
90 # not all platforms have a 'which' command
91 if which ls >/dev/null 2>/dev/null; then
98 if test -x "$p/$1" -a -f "$p/$1"; then
110 # Search for OpenSSL headers and print versions
112 echo Searching for OpenSSL header files.
113 if [ -x "`which locate`" ]
115 headers=`locate opensslv.h`
117 headers=`find / -name opensslv.h -print 2>/dev/null`
120 for header in $headers
122 ver=`awk '/OPENSSL_VERSION_NUMBER/{printf \$3}' $header`
128 # Search for shared libraries.
129 # Relies on shared libraries looking like "libcrypto.s*"
131 echo Searching for OpenSSL shared library files.
132 if [ -x "`which locate`" ]
134 libraries=`locate libcrypto.s`
136 libraries=`find / -name 'libcrypto.s*' -print 2>/dev/null`
139 for lib in $libraries
141 (echo "Trying libcrypto $lib" >>findssl.log
143 LIBPATH="$dir:$LIBPATH"
144 LD_LIBRARY_PATH="$dir:$LIBPATH"
145 LIBRARY_PATH="$dir:$LIBPATH"
146 export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH
147 ${CC} -o conftest conftest.c $lib 2>>findssl.log
150 ver=`./conftest 2>/dev/null`
158 # Search for static OpenSSL libraries and print versions
160 echo Searching for OpenSSL static library files.
161 if [ -x "`which locate`" ]
163 libraries=`locate libcrypto.a`
165 libraries=`find / -name libcrypto.a -print 2>/dev/null`
168 for lib in $libraries
170 libdir=`dirname $lib`
171 echo "Trying libcrypto $lib" >>findssl.log
172 ${CC} ${STATIC} -o conftest conftest.c -L${libdir} -lcrypto 2>>findssl.log
175 ver=`./conftest 2>/dev/null`