1#!/bin/sh 2# 3# findssl.sh 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. 8# 9# Written by Darren Tucker (dtucker at zip dot com dot au) 10# This file is placed in the public domain. 11# 12# $Id: findssl.sh,v 1.2 2003/11/21 12:48:56 djm Exp $ 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# 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 20# the cause. 21# 22# The output of configure will tell you the versions of the OpenSSL 23# headers and libraries that were picked up, for example: 24# 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 29# 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: 35 36# $ ./findssl.sh 37# Searching for OpenSSL header files. 38# 0x0090604fL /usr/include/openssl/opensslv.h 39# 0x0090604fL /usr/local/ssl/include/openssl/opensslv.h 40# 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 49# 50# Searching for OpenSSL static library files. 51# 0x0090602fL /usr/lib/libcrypto.a 52# 0x0090604fL /usr/local/ssl/lib/libcrypto.a 53# 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). 57 58# 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. 62# 63CC=gcc 64STATIC=-static 65 66# 67# Set up conftest C source 68# 69rm -f findssl.log 70cat >conftest.c <<EOD 71#include <stdio.h> 72int main(){printf("0x%08xL\n", SSLeay());} 73EOD 74 75# 76# Set default library paths if not already set 77# 78DEFAULT_LIBPATH=/usr/lib:/usr/local/lib 79LIBPATH=${LIBPATH:=$DEFAULT_LIBPATH} 80LD_LIBRARY_PATH=${LD_LIBRARY_PATH:=$DEFAULT_LIBPATH} 81LIBRARY_PATH=${LIBRARY_PATH:=$DEFAULT_LIBPATH} 82export LIBPATH LD_LIBRARY_PATH LIBRARY_PATH 83 84# 85# Search for OpenSSL headers and print versions 86# 87echo Searching for OpenSSL header files. 88if [ -x "`which locate`" ] 89then 90 headers=`locate opensslv.h` 91else 92 headers=`find / -name opensslv.h -print 2>/dev/null` 93fi 94 95for header in $headers 96do 97 ver=`awk '/OPENSSL_VERSION_NUMBER/{printf \$3}' $header` 98 echo "$ver $header" 99done 100echo 101 102# 103# Search for shared libraries. 104# Relies on shared libraries looking like "libcrypto.s*" 105# 106echo Searching for OpenSSL shared library files. 107if [ -x "`which locate`" ] 108then 109 libraries=`locate libcrypto.s` 110else 111 libraries=`find / -name 'libcrypto.s*' -print 2>/dev/null` 112fi 113 114for lib in $libraries 115do 116 (echo "Trying libcrypto $lib" >>findssl.log 117 dir=`dirname $lib` 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 123 if [ -x ./conftest ] 124 then 125 ver=`./conftest 2>/dev/null` 126 rm -f ./conftest 127 echo "$ver $lib" 128 fi) 129done 130echo 131 132# 133# Search for static OpenSSL libraries and print versions 134# 135echo Searching for OpenSSL static library files. 136if [ -x "`which locate`" ] 137then 138 libraries=`locate libcrypto.a` 139else 140 libraries=`find / -name libcrypto.a -print 2>/dev/null` 141fi 142 143for lib in $libraries 144do 145 libdir=`dirname $lib` 146 echo "Trying libcrypto $lib" >>findssl.log 147 ${CC} ${STATIC} -o conftest conftest.c -L${libdir} -lcrypto 2>>findssl.log 148 if [ -x ./conftest ] 149 then 150 ver=`./conftest 2>/dev/null` 151 rm -f ./conftest 152 echo "$ver $lib" 153 fi 154done 155 156# 157# Clean up 158# 159rm -f conftest.c 160