155714Skris 255714Skris INSTALLATION ON THE UNIX PLATFORM 355714Skris --------------------------------- 455714Skris 5160814Ssimon [Installation on DOS (with djgpp), Windows, OpenVMS, MacOS (before MacOS X) 6160814Ssimon and NetWare is described in INSTALL.DJGPP, INSTALL.W32, INSTALL.VMS, 7160814Ssimon INSTALL.MacOS and INSTALL.NW. 8160814Ssimon 9109998Smarkm This document describes installation on operating systems in the Unix 10109998Smarkm family.] 1155714Skris 1255714Skris To install OpenSSL, you will need: 1355714Skris 1479998Skris * make 1555714Skris * Perl 5 1655714Skris * an ANSI C compiler 1779998Skris * a development environment in form of development libraries and C 1879998Skris header files 1955714Skris * a supported Unix operating system 2055714Skris 2155714Skris Quick Start 2255714Skris ----------- 2355714Skris 2455714Skris If you want to just get on with it, do: 2555714Skris 2655714Skris $ ./config 2755714Skris $ make 2855714Skris $ make test 2955714Skris $ make install 3055714Skris 3155714Skris [If any of these steps fails, see section Installation in Detail below.] 3255714Skris 3355714Skris This will build and install OpenSSL in the default location, which is (for 3455714Skris historical reasons) /usr/local/ssl. If you want to install it anywhere else, 3555714Skris run config like this: 3655714Skris 3755714Skris $ ./config --prefix=/usr/local --openssldir=/usr/local/openssl 3855714Skris 3955714Skris 4055714Skris Configuration Options 4155714Skris --------------------- 4255714Skris 4359191Skris There are several options to ./config (or ./Configure) to customize 4459191Skris the build: 4555714Skris 4655714Skris --prefix=DIR Install in DIR/bin, DIR/lib, DIR/include/openssl. 4755714Skris Configuration files used by OpenSSL will be in DIR/ssl 4855714Skris or the directory specified by --openssldir. 4955714Skris 5055714Skris --openssldir=DIR Directory for OpenSSL files. If no prefix is specified, 5155714Skris the library files and binaries are also installed there. 5255714Skris 5355714Skris no-threads Don't try to build with support for multi-threaded 5455714Skris applications. 5555714Skris 5655714Skris threads Build with support for multi-threaded applications. 5755714Skris This will usually require additional system-dependent options! 5855714Skris See "Note on multi-threading" below. 5955714Skris 60109998Smarkm no-zlib Don't try to build with support for zlib compression and 61109998Smarkm decompression. 62109998Smarkm 63109998Smarkm zlib Build with support for zlib compression/decompression. 64109998Smarkm 65109998Smarkm zlib-dynamic Like "zlib", but has OpenSSL load the zlib library dynamically 66109998Smarkm when needed. This is only supported on systems where loading 67109998Smarkm of shared libraries is supported. This is the default choice. 68109998Smarkm 6968651Skris no-shared Don't try to create shared libraries. 7068651Skris 7168651Skris shared In addition to the usual static libraries, create shared 7268651Skris libraries on platforms where it's supported. See "Note on 7368651Skris shared libraries" below. 7468651Skris 7555714Skris no-asm Do not use assembler code. 7655714Skris 7755714Skris 386 Use the 80386 instruction set only (the default x86 code is 78160814Ssimon more efficient, but requires at least a 486). Note: Use 79160814Ssimon compiler flags for any other CPU specific configuration, 80160814Ssimon e.g. "-m32" to build x86 code on an x64 system. 8155714Skris 82160814Ssimon no-sse2 Exclude SSE2 code pathes. Normally SSE2 extention is 83160814Ssimon detected at run-time, but the decision whether or not the 84160814Ssimon machine code will be executed is taken solely on CPU 85160814Ssimon capability vector. This means that if you happen to run OS 86160814Ssimon kernel which does not support SSE2 extension on Intel P4 87160814Ssimon processor, then your application might be exposed to 88160814Ssimon "illegal instruction" exception. There might be a way 89160814Ssimon to enable support in kernel, e.g. FreeBSD kernel can be 90160814Ssimon compiled with CPU_ENABLE_SSE, and there is a way to 91160814Ssimon disengage SSE2 code pathes upon application start-up, 92160814Ssimon but if you aim for wider "audience" running such kernel, 93160814Ssimon consider no-sse2. Both 386 and no-asm options above imply 94160814Ssimon no-sse2. 95160814Ssimon 9655714Skris no-<cipher> Build without the specified cipher (bf, cast, des, dh, dsa, 9755714Skris hmac, md2, md5, mdc2, rc2, rc4, rc5, rsa, sha). 9855714Skris The crypto/<cipher> directory can be removed after running 9955714Skris "make depend". 10055714Skris 101238405Sjkim -Dxxx, -lxxx, -Lxxx, -fxxx, -mXXX, -Kxxx These system specific options will 10255714Skris be passed through to the compiler to allow you to 10355714Skris define preprocessor symbols, specify additional libraries, 10455714Skris library directories or other compiler options. 10555714Skris 106238405Sjkim -DHAVE_CRYPTODEV Enable the BSD cryptodev engine even if we are not using 107238405Sjkim BSD. Useful if you are running ocf-linux or something 108238405Sjkim similar. Once enabled you can also enable the use of 109238405Sjkim cryptodev digests, which is usually slower unless you have 110238405Sjkim large amounts data. Use -DUSE_CRYPTODEV_DIGESTS to force 111238405Sjkim it. 11255714Skris 11355714Skris Installation in Detail 11455714Skris ---------------------- 11555714Skris 11655714Skris 1a. Configure OpenSSL for your operation system automatically: 11755714Skris 11855714Skris $ ./config [options] 11955714Skris 12055714Skris This guesses at your operating system (and compiler, if necessary) and 12155714Skris configures OpenSSL based on this guess. Run ./config -t to see 12259191Skris if it guessed correctly. If you want to use a different compiler, you 12359191Skris are cross-compiling for another platform, or the ./config guess was 12459191Skris wrong for other reasons, go to step 1b. Otherwise go to step 2. 12555714Skris 12655714Skris On some systems, you can include debugging information as follows: 12755714Skris 12855714Skris $ ./config -d [options] 12955714Skris 13055714Skris 1b. Configure OpenSSL for your operating system manually 13155714Skris 13255714Skris OpenSSL knows about a range of different operating system, hardware and 13355714Skris compiler combinations. To see the ones it knows about, run 13455714Skris 13555714Skris $ ./Configure 13655714Skris 13755714Skris Pick a suitable name from the list that matches your system. For most 13855714Skris operating systems there is a choice between using "cc" or "gcc". When 13955714Skris you have identified your system (and if necessary compiler) use this name 14055714Skris as the argument to ./Configure. For example, a "linux-elf" user would 14155714Skris run: 14255714Skris 14355714Skris $ ./Configure linux-elf [options] 14455714Skris 14555714Skris If your system is not available, you will have to edit the Configure 14655714Skris program and add the correct configuration for your system. The 14759191Skris generic configurations "cc" or "gcc" should usually work on 32 bit 14859191Skris systems. 14955714Skris 150160814Ssimon Configure creates the file Makefile.ssl from Makefile.org and 15155714Skris defines various macros in crypto/opensslconf.h (generated from 15255714Skris crypto/opensslconf.h.in). 15355714Skris 15455714Skris 2. Build OpenSSL by running: 15555714Skris 15655714Skris $ make 15755714Skris 15855714Skris This will build the OpenSSL libraries (libcrypto.a and libssl.a) and the 15955714Skris OpenSSL binary ("openssl"). The libraries will be built in the top-level 16055714Skris directory, and the binary will be in the "apps" directory. 16155714Skris 16268651Skris If "make" fails, look at the output. There may be reasons for 16379998Skris the failure that aren't problems in OpenSSL itself (like missing 16468651Skris standard headers). If it is a problem with OpenSSL itself, please 16568651Skris report the problem to <openssl-bugs@openssl.org> (note that your 166100936Snectar message will be recorded in the request tracker publicly readable 167194206Ssimon via http://www.openssl.org/support/rt.html and will be forwarded to a 168109998Smarkm public mailing list). Include the output of "make report" in your message. 169100936Snectar Please check out the request tracker. Maybe the bug was already 170100936Snectar reported or has already been fixed. 17155714Skris 17255714Skris [If you encounter assembler error messages, try the "no-asm" 17359191Skris configuration option as an immediate fix.] 17455714Skris 17555714Skris Compiling parts of OpenSSL with gcc and others with the system 17655714Skris compiler will result in unresolved symbols on some systems. 17755714Skris 17855714Skris 3. After a successful build, the libraries should be tested. Run: 17955714Skris 18055714Skris $ make test 18155714Skris 18268651Skris If a test fails, look at the output. There may be reasons for 18368651Skris the failure that isn't a problem in OpenSSL itself (like a missing 18468651Skris or malfunctioning bc). If it is a problem with OpenSSL itself, 185111147Snectar try removing any compiler optimization flags from the CFLAG line 186160814Ssimon in Makefile.ssl and run "make clean; make". Please send a bug 18768651Skris report to <openssl-bugs@openssl.org>, including the output of 188100936Snectar "make report" in order to be added to the request tracker at 189194206Ssimon http://www.openssl.org/support/rt.html. 19055714Skris 19155714Skris 4. If everything tests ok, install OpenSSL with 19255714Skris 19355714Skris $ make install 19455714Skris 19555714Skris This will create the installation directory (if it does not exist) and 19655714Skris then the following subdirectories: 19755714Skris 19855714Skris certs Initially empty, this is the default location 19955714Skris for certificate files. 20059191Skris man/man1 Manual pages for the 'openssl' command line tool 20159191Skris man/man3 Manual pages for the libraries (very incomplete) 20255714Skris misc Various scripts. 20355714Skris private Initially empty, this is the default location 20455714Skris for private key files. 20555714Skris 20659191Skris If you didn't choose a different installation prefix, the 20755714Skris following additional subdirectories will be created: 20855714Skris 20955714Skris bin Contains the openssl binary and a few other 21055714Skris utility programs. 21155714Skris include/openssl Contains the header files needed if you want to 21255714Skris compile programs with libcrypto or libssl. 21355714Skris lib Contains the OpenSSL library files themselves. 21455714Skris 215238405Sjkim Use "make install_sw" to install the software without documentation, 216238405Sjkim and "install_docs_html" to install HTML renditions of the manual 217238405Sjkim pages. 218238405Sjkim 21955714Skris Package builders who want to configure the library for standard 22055714Skris locations, but have the package installed somewhere else so that 22155714Skris it can easily be packaged, can use 22255714Skris 22355714Skris $ make INSTALL_PREFIX=/tmp/package-root install 22455714Skris 22555714Skris (or specify "--install_prefix=/tmp/package-root" as a configure 22655714Skris option). The specified prefix will be prepended to all 22755714Skris installation target filenames. 22855714Skris 22955714Skris 23055714Skris NOTE: The header files used to reside directly in the include 23155714Skris directory, but have now been moved to include/openssl so that 23255714Skris OpenSSL can co-exist with other libraries which use some of the 23355714Skris same filenames. This means that applications that use OpenSSL 23455714Skris should now use C preprocessor directives of the form 23555714Skris 23655714Skris #include <openssl/ssl.h> 23755714Skris 23855714Skris instead of "#include <ssl.h>", which was used with library versions 23955714Skris up to OpenSSL 0.9.2b. 24055714Skris 24155714Skris If you install a new version of OpenSSL over an old library version, 24255714Skris you should delete the old header files in the include directory. 24355714Skris 24455714Skris Compatibility issues: 24555714Skris 24655714Skris * COMPILING existing applications 24755714Skris 24855714Skris To compile an application that uses old filenames -- e.g. 24955714Skris "#include <ssl.h>" --, it will usually be enough to find 25055714Skris the CFLAGS definition in the application's Makefile and 25155714Skris add a C option such as 25255714Skris 25355714Skris -I/usr/local/ssl/include/openssl 25455714Skris 25555714Skris to it. 25655714Skris 25755714Skris But don't delete the existing -I option that points to 25855714Skris the ..../include directory! Otherwise, OpenSSL header files 25955714Skris could not #include each other. 26055714Skris 26155714Skris * WRITING applications 26255714Skris 26355714Skris To write an application that is able to handle both the new 26455714Skris and the old directory layout, so that it can still be compiled 26555714Skris with library versions up to OpenSSL 0.9.2b without bothering 26655714Skris the user, you can proceed as follows: 26755714Skris 26855714Skris - Always use the new filename of OpenSSL header files, 26955714Skris e.g. #include <openssl/ssl.h>. 27055714Skris 27155714Skris - Create a directory "incl" that contains only a symbolic 27255714Skris link named "openssl", which points to the "include" directory 27355714Skris of OpenSSL. 27455714Skris For example, your application's Makefile might contain the 27555714Skris following rule, if OPENSSLDIR is a pathname (absolute or 27655714Skris relative) of the directory where OpenSSL resides: 27755714Skris 27855714Skris incl/openssl: 27955714Skris -mkdir incl 28055714Skris cd $(OPENSSLDIR) # Check whether the directory really exists 28155714Skris -ln -s `cd $(OPENSSLDIR); pwd`/include incl/openssl 28255714Skris 28355714Skris You will have to add "incl/openssl" to the dependencies 28455714Skris of those C files that include some OpenSSL header file. 28555714Skris 28655714Skris - Add "-Iincl" to your CFLAGS. 28755714Skris 28855714Skris With these additions, the OpenSSL header files will be available 28955714Skris under both name variants if an old library version is used: 29055714Skris Your application can reach them under names like <openssl/foo.h>, 29155714Skris while the header files still are able to #include each other 29255714Skris with names of the form <foo.h>. 29355714Skris 29455714Skris 29555714Skris Note on multi-threading 29655714Skris ----------------------- 29755714Skris 29855714Skris For some systems, the OpenSSL Configure script knows what compiler options 29955714Skris are needed to generate a library that is suitable for multi-threaded 30055714Skris applications. On these systems, support for multi-threading is enabled 30155714Skris by default; use the "no-threads" option to disable (this should never be 30255714Skris necessary). 30355714Skris 30455714Skris On other systems, to enable support for multi-threading, you will have 30555714Skris to specify at least two options: "threads", and a system-dependent option. 30655714Skris (The latter is "-D_REENTRANT" on various systems.) The default in this 30755714Skris case, obviously, is not to include support for multi-threading (but 30855714Skris you can still use "no-threads" to suppress an annoying warning message 30955714Skris from the Configure script.) 31055714Skris 31168651Skris 31268651Skris Note on shared libraries 31368651Skris ------------------------ 31468651Skris 315167612Ssimon Shared libraries have certain caveats. Binary backward compatibility 316167612Ssimon can't be guaranteed before OpenSSL version 1.0. The only reason to 317167612Ssimon use them would be to conserve memory on systems where several programs 318167612Ssimon are using OpenSSL. 319100928Snectar 32068651Skris For some systems, the OpenSSL Configure script knows what is needed to 32168651Skris build shared libraries for libcrypto and libssl. On these systems, 32268651Skris the shared libraries are currently not created by default, but giving 32368651Skris the option "shared" will get them created. This method supports Makefile 32468651Skris targets for shared library creation, like linux-shared. Those targets 32568651Skris can currently be used on their own just as well, but this is expected 32668651Skris to change in future versions of OpenSSL. 327109998Smarkm 328109998Smarkm Note on random number generation 329109998Smarkm -------------------------------- 330109998Smarkm 331109998Smarkm Availability of cryptographically secure random numbers is required for 332109998Smarkm secret key generation. OpenSSL provides several options to seed the 333109998Smarkm internal PRNG. If not properly seeded, the internal PRNG will refuse 334109998Smarkm to deliver random bytes and a "PRNG not seeded error" will occur. 335109998Smarkm On systems without /dev/urandom (or similar) device, it may be necessary 336109998Smarkm to install additional support software to obtain random seed. 337109998Smarkm Please check out the manual pages for RAND_add(), RAND_bytes(), RAND_egd(), 338109998Smarkm and the FAQ for more information. 339111147Snectar 340111147Snectar Note on support for multiple builds 341111147Snectar ----------------------------------- 342111147Snectar 343160814Ssimon OpenSSL is usually built in its source tree. Unfortunately, this doesn't 344111147Snectar support building for multiple platforms from the same source tree very well. 345111147Snectar It is however possible to build in a separate tree through the use of lots 346111147Snectar of symbolic links, which should be prepared like this: 347111147Snectar 348111147Snectar mkdir -p objtree/"`uname -s`-`uname -r`-`uname -m`" 349111147Snectar cd objtree/"`uname -s`-`uname -r`-`uname -m`" 350111147Snectar (cd $OPENSSL_SOURCE; find . -type f) | while read F; do 351111147Snectar mkdir -p `dirname $F` 352111147Snectar rm -f $F; ln -s $OPENSSL_SOURCE/$F $F 353111147Snectar echo $F '->' $OPENSSL_SOURCE/$F 354111147Snectar done 355111147Snectar make -f Makefile.org clean 356111147Snectar 357111147Snectar OPENSSL_SOURCE is an environment variable that contains the absolute (this 358111147Snectar is important!) path to the OpenSSL source tree. 359111147Snectar 360111147Snectar Also, operations like 'make update' should still be made in the source tree. 361