xref: /onnv-gate/usr/src/common/openssl/FAQ (revision 2139:6243c3338933)
10Sstevel@tonic-gateOpenSSL  -  Frequently Asked Questions
20Sstevel@tonic-gate--------------------------------------
30Sstevel@tonic-gate
40Sstevel@tonic-gate[MISC] Miscellaneous questions
50Sstevel@tonic-gate
60Sstevel@tonic-gate* Which is the current version of OpenSSL?
70Sstevel@tonic-gate* Where is the documentation?
80Sstevel@tonic-gate* How can I contact the OpenSSL developers?
90Sstevel@tonic-gate* Where can I get a compiled version of OpenSSL?
100Sstevel@tonic-gate* Why aren't tools like 'autoconf' and 'libtool' used?
110Sstevel@tonic-gate* What is an 'engine' version?
120Sstevel@tonic-gate* How do I check the authenticity of the OpenSSL distribution?
130Sstevel@tonic-gate
140Sstevel@tonic-gate[LEGAL] Legal questions
150Sstevel@tonic-gate
160Sstevel@tonic-gate* Do I need patent licenses to use OpenSSL?
170Sstevel@tonic-gate* Can I use OpenSSL with GPL software?
180Sstevel@tonic-gate
190Sstevel@tonic-gate[USER] Questions on using the OpenSSL applications
200Sstevel@tonic-gate
210Sstevel@tonic-gate* Why do I get a "PRNG not seeded" error message?
220Sstevel@tonic-gate* Why do I get an "unable to write 'random state'" error message?
230Sstevel@tonic-gate* How do I create certificates or certificate requests?
240Sstevel@tonic-gate* Why can't I create certificate requests?
250Sstevel@tonic-gate* Why does <SSL program> fail with a certificate verify error?
260Sstevel@tonic-gate* Why can I only use weak ciphers when I connect to a server using OpenSSL?
270Sstevel@tonic-gate* How can I create DSA certificates?
280Sstevel@tonic-gate* Why can't I make an SSL connection using a DSA certificate?
290Sstevel@tonic-gate* How can I remove the passphrase on a private key?
300Sstevel@tonic-gate* Why can't I use OpenSSL certificates with SSL client authentication?
310Sstevel@tonic-gate* Why does my browser give a warning about a mismatched hostname?
320Sstevel@tonic-gate* How do I install a CA certificate into a browser?
330Sstevel@tonic-gate* Why is OpenSSL x509 DN output not conformant to RFC2253?
340Sstevel@tonic-gate
350Sstevel@tonic-gate[BUILD] Questions about building and testing OpenSSL
360Sstevel@tonic-gate
370Sstevel@tonic-gate* Why does the linker complain about undefined symbols?
380Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: command not found"?
390Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: 1 no implemented"?
400Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: stack empty"?
410Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
420Sstevel@tonic-gate* Why does the OpenSSL compilation fail with "ar: command not found"?
430Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Win32 with VC++?
440Sstevel@tonic-gate* What is special about OpenSSL on Redhat?
450Sstevel@tonic-gate* Why does the OpenSSL compilation fail on MacOS X?
460Sstevel@tonic-gate* Why does the OpenSSL test suite fail on MacOS X?
470Sstevel@tonic-gate* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]?
480Sstevel@tonic-gate* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"?
49*2139Sjp161948* Why does the OpenSSL test suite fail in sha512t on x86 CPU?
50*2139Sjp161948* Why does compiler fail to compile sha512.c?
510Sstevel@tonic-gate
520Sstevel@tonic-gate[PROG] Questions about programming with OpenSSL
530Sstevel@tonic-gate
540Sstevel@tonic-gate* Is OpenSSL thread-safe?
550Sstevel@tonic-gate* I've compiled a program under Windows and it crashes: why?
560Sstevel@tonic-gate* How do I read or write a DER encoded buffer using the ASN1 functions?
57*2139Sjp161948* OpenSSL uses DER but I need BER format: does OpenSSL support BER?
580Sstevel@tonic-gate* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?
590Sstevel@tonic-gate* I've called <some function> and it fails, why?
600Sstevel@tonic-gate* I just get a load of numbers for the error output, what do they mean?
610Sstevel@tonic-gate* Why do I get errors about unknown algorithms?
620Sstevel@tonic-gate* Why can't the OpenSSH configure script detect OpenSSL?
630Sstevel@tonic-gate* Can I use OpenSSL's SSL library with non-blocking I/O?
640Sstevel@tonic-gate* Why doesn't my server application receive a client certificate?
650Sstevel@tonic-gate* Why does compilation fail due to an undefined symbol NID_uniqueIdentifier?
66*2139Sjp161948* I think I've detected a memory leak, is this a bug?
670Sstevel@tonic-gate
680Sstevel@tonic-gate===============================================================================
690Sstevel@tonic-gate
700Sstevel@tonic-gate[MISC] ========================================================================
710Sstevel@tonic-gate
720Sstevel@tonic-gate* Which is the current version of OpenSSL?
730Sstevel@tonic-gate
740Sstevel@tonic-gateThe current version is available from <URL: http://www.openssl.org>.
75*2139Sjp161948OpenSSL 0.9.8a was released on October 11th, 2005.
760Sstevel@tonic-gate
770Sstevel@tonic-gateIn addition to the current stable release, you can also access daily
780Sstevel@tonic-gatesnapshots of the OpenSSL development version at <URL:
790Sstevel@tonic-gateftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access.
800Sstevel@tonic-gate
810Sstevel@tonic-gate
820Sstevel@tonic-gate* Where is the documentation?
830Sstevel@tonic-gate
840Sstevel@tonic-gateOpenSSL is a library that provides cryptographic functionality to
850Sstevel@tonic-gateapplications such as secure web servers.  Be sure to read the
860Sstevel@tonic-gatedocumentation of the application you want to use.  The INSTALL file
870Sstevel@tonic-gateexplains how to install this library.
880Sstevel@tonic-gate
890Sstevel@tonic-gateOpenSSL includes a command line utility that can be used to perform a
900Sstevel@tonic-gatevariety of cryptographic functions.  It is described in the openssl(1)
910Sstevel@tonic-gatemanpage.  Documentation for developers is currently being written.  A
920Sstevel@tonic-gatefew manual pages already are available; overviews over libcrypto and
930Sstevel@tonic-gatelibssl are given in the crypto(3) and ssl(3) manpages.
940Sstevel@tonic-gate
950Sstevel@tonic-gateThe OpenSSL manpages are installed in /usr/local/ssl/man/ (or a
960Sstevel@tonic-gatedifferent directory if you specified one as described in INSTALL).
970Sstevel@tonic-gateIn addition, you can read the most current versions at
980Sstevel@tonic-gate<URL: http://www.openssl.org/docs/>.
990Sstevel@tonic-gate
1000Sstevel@tonic-gateFor information on parts of libcrypto that are not yet documented, you
1010Sstevel@tonic-gatemight want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's
1020Sstevel@tonic-gatepredecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>.  Much
1030Sstevel@tonic-gateof this still applies to OpenSSL.
1040Sstevel@tonic-gate
1050Sstevel@tonic-gateThere is some documentation about certificate extensions and PKCS#12
1060Sstevel@tonic-gatein doc/openssl.txt
1070Sstevel@tonic-gate
1080Sstevel@tonic-gateThe original SSLeay documentation is included in OpenSSL as
1090Sstevel@tonic-gatedoc/ssleay.txt.  It may be useful when none of the other resources
1100Sstevel@tonic-gatehelp, but please note that it reflects the obsolete version SSLeay
1110Sstevel@tonic-gate0.6.6.
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate
1140Sstevel@tonic-gate* How can I contact the OpenSSL developers?
1150Sstevel@tonic-gate
1160Sstevel@tonic-gateThe README file describes how to submit bug reports and patches to
1170Sstevel@tonic-gateOpenSSL.  Information on the OpenSSL mailing lists is available from
1180Sstevel@tonic-gate<URL: http://www.openssl.org>.
1190Sstevel@tonic-gate
1200Sstevel@tonic-gate
1210Sstevel@tonic-gate* Where can I get a compiled version of OpenSSL?
1220Sstevel@tonic-gate
1230Sstevel@tonic-gateYou can finder pointers to binary distributions in
1240Sstevel@tonic-gatehttp://www.openssl.org/related/binaries.html .
1250Sstevel@tonic-gate
1260Sstevel@tonic-gateSome applications that use OpenSSL are distributed in binary form.
1270Sstevel@tonic-gateWhen using such an application, you don't need to install OpenSSL
1280Sstevel@tonic-gateyourself; the application will include the required parts (e.g. DLLs).
1290Sstevel@tonic-gate
1300Sstevel@tonic-gateIf you want to build OpenSSL on a Windows system and you don't have
1310Sstevel@tonic-gatea C compiler, read the "Mingw32" section of INSTALL.W32 for information
1320Sstevel@tonic-gateon how to obtain and install the free GNU C compiler.
1330Sstevel@tonic-gate
1340Sstevel@tonic-gateA number of Linux and *BSD distributions include OpenSSL.
1350Sstevel@tonic-gate
1360Sstevel@tonic-gate
1370Sstevel@tonic-gate* Why aren't tools like 'autoconf' and 'libtool' used?
1380Sstevel@tonic-gate
1390Sstevel@tonic-gateautoconf will probably be used in future OpenSSL versions. If it was
1400Sstevel@tonic-gateless Unix-centric, it might have been used much earlier.
1410Sstevel@tonic-gate
1420Sstevel@tonic-gate* What is an 'engine' version?
1430Sstevel@tonic-gate
1440Sstevel@tonic-gateWith version 0.9.6 OpenSSL was extended to interface to external crypto
1450Sstevel@tonic-gatehardware. This was realized in a special release '0.9.6-engine'. With
146*2139Sjp161948version 0.9.7 the changes were merged into the main development line,
147*2139Sjp161948so that the special release is no longer necessary.
1480Sstevel@tonic-gate
1490Sstevel@tonic-gate* How do I check the authenticity of the OpenSSL distribution?
1500Sstevel@tonic-gate
1510Sstevel@tonic-gateWe provide MD5 digests and ASC signatures of each tarball.
1520Sstevel@tonic-gateUse MD5 to check that a tarball from a mirror site is identical:
1530Sstevel@tonic-gate
1540Sstevel@tonic-gate   md5sum TARBALL | awk '{print $1;}' | cmp - TARBALL.md5
1550Sstevel@tonic-gate
1560Sstevel@tonic-gateYou can check authenticity using pgp or gpg. You need the OpenSSL team
157*2139Sjp161948member public key used to sign it (download it from a key server, see a
158*2139Sjp161948list of keys at <URL: http://www.openssl.org/about/>). Then
1590Sstevel@tonic-gatejust do:
1600Sstevel@tonic-gate
1610Sstevel@tonic-gate   pgp TARBALL.asc
1620Sstevel@tonic-gate
1630Sstevel@tonic-gate[LEGAL] =======================================================================
1640Sstevel@tonic-gate
1650Sstevel@tonic-gate* Do I need patent licenses to use OpenSSL?
1660Sstevel@tonic-gate
1670Sstevel@tonic-gateThe patents section of the README file lists patents that may apply to
1680Sstevel@tonic-gateyou if you want to use OpenSSL.  For information on intellectual
1690Sstevel@tonic-gateproperty rights, please consult a lawyer.  The OpenSSL team does not
1700Sstevel@tonic-gateoffer legal advice.
1710Sstevel@tonic-gate
172*2139Sjp161948You can configure OpenSSL so as not to use IDEA, MDC2 and RC5 by using
173*2139Sjp161948 ./config no-idea no-mdc2 no-rc5
1740Sstevel@tonic-gate
1750Sstevel@tonic-gate
1760Sstevel@tonic-gate* Can I use OpenSSL with GPL software?
1770Sstevel@tonic-gate
1780Sstevel@tonic-gateOn many systems including the major Linux and BSD distributions, yes (the
1790Sstevel@tonic-gateGPL does not place restrictions on using libraries that are part of the
1800Sstevel@tonic-gatenormal operating system distribution).
1810Sstevel@tonic-gate
1820Sstevel@tonic-gateOn other systems, the situation is less clear. Some GPL software copyright
1830Sstevel@tonic-gateholders claim that you infringe on their rights if you use OpenSSL with
1840Sstevel@tonic-gatetheir software on operating systems that don't normally include OpenSSL.
1850Sstevel@tonic-gate
1860Sstevel@tonic-gateIf you develop open source software that uses OpenSSL, you may find it
1870Sstevel@tonic-gateuseful to choose an other license than the GPL, or state explicitly that
1880Sstevel@tonic-gate"This program is released under the GPL with the additional exemption that
1890Sstevel@tonic-gatecompiling, linking, and/or using OpenSSL is allowed."  If you are using
1900Sstevel@tonic-gateGPL software developed by others, you may want to ask the copyright holder
1910Sstevel@tonic-gatefor permission to use their software with OpenSSL.
1920Sstevel@tonic-gate
1930Sstevel@tonic-gate
1940Sstevel@tonic-gate[USER] ========================================================================
1950Sstevel@tonic-gate
1960Sstevel@tonic-gate* Why do I get a "PRNG not seeded" error message?
1970Sstevel@tonic-gate
1980Sstevel@tonic-gateCryptographic software needs a source of unpredictable data to work
1990Sstevel@tonic-gatecorrectly.  Many open source operating systems provide a "randomness
2000Sstevel@tonic-gatedevice" (/dev/urandom or /dev/random) that serves this purpose.
2010Sstevel@tonic-gateAll OpenSSL versions try to use /dev/urandom by default; starting with
2020Sstevel@tonic-gateversion 0.9.7, OpenSSL also tries /dev/random if /dev/urandom is not
2030Sstevel@tonic-gateavailable.
2040Sstevel@tonic-gate
2050Sstevel@tonic-gateOn other systems, applications have to call the RAND_add() or
2060Sstevel@tonic-gateRAND_seed() function with appropriate data before generating keys or
2070Sstevel@tonic-gateperforming public key encryption. (These functions initialize the
2080Sstevel@tonic-gatepseudo-random number generator, PRNG.)  Some broken applications do
2090Sstevel@tonic-gatenot do this.  As of version 0.9.5, the OpenSSL functions that need
2100Sstevel@tonic-gaterandomness report an error if the random number generator has not been
2110Sstevel@tonic-gateseeded with at least 128 bits of randomness.  If this error occurs and
2120Sstevel@tonic-gateis not discussed in the documentation of the application you are
2130Sstevel@tonic-gateusing, please contact the author of that application; it is likely
2140Sstevel@tonic-gatethat it never worked correctly.  OpenSSL 0.9.5 and later make the
2150Sstevel@tonic-gateerror visible by refusing to perform potentially insecure encryption.
2160Sstevel@tonic-gate
2170Sstevel@tonic-gateIf you are using Solaris 8, you can add /dev/urandom and /dev/random
2180Sstevel@tonic-gatedevices by installing patch 112438 (Sparc) or 112439 (x86), which are
2190Sstevel@tonic-gateavailable via the Patchfinder at <URL: http://sunsolve.sun.com>
2200Sstevel@tonic-gate(Solaris 9 includes these devices by default). For /dev/random support
2210Sstevel@tonic-gatefor earlier Solaris versions, see Sun's statement at
2220Sstevel@tonic-gate<URL: http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb/27606&zone_32=SUNWski>
2230Sstevel@tonic-gate(the SUNWski package is available in patch 105710).
2240Sstevel@tonic-gate
2250Sstevel@tonic-gateOn systems without /dev/urandom and /dev/random, it is a good idea to
2260Sstevel@tonic-gateuse the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for
2270Sstevel@tonic-gatedetails.  Starting with version 0.9.7, OpenSSL will automatically look
2280Sstevel@tonic-gatefor an EGD socket at /var/run/egd-pool, /dev/egd-pool, /etc/egd-pool and
2290Sstevel@tonic-gate/etc/entropy.
2300Sstevel@tonic-gate
2310Sstevel@tonic-gateMost components of the openssl command line utility automatically try
2320Sstevel@tonic-gateto seed the random number generator from a file.  The name of the
2330Sstevel@tonic-gatedefault seeding file is determined as follows: If environment variable
2340Sstevel@tonic-gateRANDFILE is set, then it names the seeding file.  Otherwise if
2350Sstevel@tonic-gateenvironment variable HOME is set, then the seeding file is $HOME/.rnd.
2360Sstevel@tonic-gateIf neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will
2370Sstevel@tonic-gateuse file .rnd in the current directory while OpenSSL 0.9.6a uses no
2380Sstevel@tonic-gatedefault seeding file at all.  OpenSSL 0.9.6b and later will behave
2390Sstevel@tonic-gatesimilarly to 0.9.6a, but will use a default of "C:\" for HOME on
2400Sstevel@tonic-gateWindows systems if the environment variable has not been set.
2410Sstevel@tonic-gate
2420Sstevel@tonic-gateIf the default seeding file does not exist or is too short, the "PRNG
2430Sstevel@tonic-gatenot seeded" error message may occur.
2440Sstevel@tonic-gate
2450Sstevel@tonic-gateThe openssl command line utility will write back a new state to the
2460Sstevel@tonic-gatedefault seeding file (and create this file if necessary) unless
2470Sstevel@tonic-gatethere was no sufficient seeding.
2480Sstevel@tonic-gate
2490Sstevel@tonic-gatePointing $RANDFILE to an Entropy Gathering Daemon socket does not work.
2500Sstevel@tonic-gateUse the "-rand" option of the OpenSSL command line tools instead.
2510Sstevel@tonic-gateThe $RANDFILE environment variable and $HOME/.rnd are only used by the
2520Sstevel@tonic-gateOpenSSL command line tools. Applications using the OpenSSL library
2530Sstevel@tonic-gateprovide their own configuration options to specify the entropy source,
2540Sstevel@tonic-gateplease check out the documentation coming the with application.
2550Sstevel@tonic-gate
2560Sstevel@tonic-gate
2570Sstevel@tonic-gate* Why do I get an "unable to write 'random state'" error message?
2580Sstevel@tonic-gate
2590Sstevel@tonic-gate
2600Sstevel@tonic-gateSometimes the openssl command line utility does not abort with
2610Sstevel@tonic-gatea "PRNG not seeded" error message, but complains that it is
2620Sstevel@tonic-gate"unable to write 'random state'".  This message refers to the
2630Sstevel@tonic-gatedefault seeding file (see previous answer).  A possible reason
2640Sstevel@tonic-gateis that no default filename is known because neither RANDFILE
2650Sstevel@tonic-gatenor HOME is set.  (Versions up to 0.9.6 used file ".rnd" in the
2660Sstevel@tonic-gatecurrent directory in this case, but this has changed with 0.9.6a.)
2670Sstevel@tonic-gate
2680Sstevel@tonic-gate
2690Sstevel@tonic-gate* How do I create certificates or certificate requests?
2700Sstevel@tonic-gate
2710Sstevel@tonic-gateCheck out the CA.pl(1) manual page. This provides a simple wrapper round
2720Sstevel@tonic-gatethe 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check
2730Sstevel@tonic-gateout the manual pages for the individual utilities and the certificate
2740Sstevel@tonic-gateextensions documentation (currently in doc/openssl.txt).
2750Sstevel@tonic-gate
2760Sstevel@tonic-gate
2770Sstevel@tonic-gate* Why can't I create certificate requests?
2780Sstevel@tonic-gate
2790Sstevel@tonic-gateYou typically get the error:
2800Sstevel@tonic-gate
2810Sstevel@tonic-gate	unable to find 'distinguished_name' in config
2820Sstevel@tonic-gate	problems making Certificate Request
2830Sstevel@tonic-gate
2840Sstevel@tonic-gateThis is because it can't find the configuration file. Check out the
2850Sstevel@tonic-gateDIAGNOSTICS section of req(1) for more information.
2860Sstevel@tonic-gate
2870Sstevel@tonic-gate
2880Sstevel@tonic-gate* Why does <SSL program> fail with a certificate verify error?
2890Sstevel@tonic-gate
2900Sstevel@tonic-gateThis problem is usually indicated by log messages saying something like
2910Sstevel@tonic-gate"unable to get local issuer certificate" or "self signed certificate".
2920Sstevel@tonic-gateWhen a certificate is verified its root CA must be "trusted" by OpenSSL
2930Sstevel@tonic-gatethis typically means that the CA certificate must be placed in a directory
2940Sstevel@tonic-gateor file and the relevant program configured to read it. The OpenSSL program
2950Sstevel@tonic-gate'verify' behaves in a similar way and issues similar error messages: check
2960Sstevel@tonic-gatethe verify(1) program manual page for more information.
2970Sstevel@tonic-gate
2980Sstevel@tonic-gate
2990Sstevel@tonic-gate* Why can I only use weak ciphers when I connect to a server using OpenSSL?
3000Sstevel@tonic-gate
3010Sstevel@tonic-gateThis is almost certainly because you are using an old "export grade" browser
3020Sstevel@tonic-gatewhich only supports weak encryption. Upgrade your browser to support 128 bit
3030Sstevel@tonic-gateciphers.
3040Sstevel@tonic-gate
3050Sstevel@tonic-gate
3060Sstevel@tonic-gate* How can I create DSA certificates?
3070Sstevel@tonic-gate
3080Sstevel@tonic-gateCheck the CA.pl(1) manual page for a DSA certificate example.
3090Sstevel@tonic-gate
3100Sstevel@tonic-gate
3110Sstevel@tonic-gate* Why can't I make an SSL connection to a server using a DSA certificate?
3120Sstevel@tonic-gate
3130Sstevel@tonic-gateTypically you'll see a message saying there are no shared ciphers when
3140Sstevel@tonic-gatethe same setup works fine with an RSA certificate. There are two possible
3150Sstevel@tonic-gatecauses. The client may not support connections to DSA servers most web
3160Sstevel@tonic-gatebrowsers (including Netscape and MSIE) only support connections to servers
3170Sstevel@tonic-gatesupporting RSA cipher suites. The other cause is that a set of DH parameters
3180Sstevel@tonic-gatehas not been supplied to the server. DH parameters can be created with the
3190Sstevel@tonic-gatedhparam(1) command and loaded using the SSL_CTX_set_tmp_dh() for example:
3200Sstevel@tonic-gatecheck the source to s_server in apps/s_server.c for an example.
3210Sstevel@tonic-gate
3220Sstevel@tonic-gate
3230Sstevel@tonic-gate* How can I remove the passphrase on a private key?
3240Sstevel@tonic-gate
3250Sstevel@tonic-gateFirstly you should be really *really* sure you want to do this. Leaving
3260Sstevel@tonic-gatea private key unencrypted is a major security risk. If you decide that
3270Sstevel@tonic-gateyou do have to do this check the EXAMPLES sections of the rsa(1) and
3280Sstevel@tonic-gatedsa(1) manual pages.
3290Sstevel@tonic-gate
3300Sstevel@tonic-gate
3310Sstevel@tonic-gate* Why can't I use OpenSSL certificates with SSL client authentication?
3320Sstevel@tonic-gate
3330Sstevel@tonic-gateWhat will typically happen is that when a server requests authentication
3340Sstevel@tonic-gateit will either not include your certificate or tell you that you have
3350Sstevel@tonic-gateno client certificates (Netscape) or present you with an empty list box
3360Sstevel@tonic-gate(MSIE). The reason for this is that when a server requests a client
3370Sstevel@tonic-gatecertificate it includes a list of CAs names which it will accept. Browsers
3380Sstevel@tonic-gatewill only let you select certificates from the list on the grounds that
3390Sstevel@tonic-gatethere is little point presenting a certificate which the server will
3400Sstevel@tonic-gatereject.
3410Sstevel@tonic-gate
3420Sstevel@tonic-gateThe solution is to add the relevant CA certificate to your servers "trusted
3430Sstevel@tonic-gateCA list". How you do this depends on the server software in uses. You can
3440Sstevel@tonic-gateprint out the servers list of acceptable CAs using the OpenSSL s_client tool:
3450Sstevel@tonic-gate
3460Sstevel@tonic-gateopenssl s_client -connect www.some.host:443 -prexit
3470Sstevel@tonic-gate
3480Sstevel@tonic-gateIf your server only requests certificates on certain URLs then you may need
3490Sstevel@tonic-gateto manually issue an HTTP GET command to get the list when s_client connects:
3500Sstevel@tonic-gate
3510Sstevel@tonic-gateGET /some/page/needing/a/certificate.html
3520Sstevel@tonic-gate
3530Sstevel@tonic-gateIf your CA does not appear in the list then this confirms the problem.
3540Sstevel@tonic-gate
3550Sstevel@tonic-gate
3560Sstevel@tonic-gate* Why does my browser give a warning about a mismatched hostname?
3570Sstevel@tonic-gate
3580Sstevel@tonic-gateBrowsers expect the server's hostname to match the value in the commonName
3590Sstevel@tonic-gate(CN) field of the certificate. If it does not then you get a warning.
3600Sstevel@tonic-gate
3610Sstevel@tonic-gate
3620Sstevel@tonic-gate* How do I install a CA certificate into a browser?
3630Sstevel@tonic-gate
3640Sstevel@tonic-gateThe usual way is to send the DER encoded certificate to the browser as
3650Sstevel@tonic-gateMIME type application/x-x509-ca-cert, for example by clicking on an appropriate
3660Sstevel@tonic-gatelink. On MSIE certain extensions such as .der or .cacert may also work, or you
3670Sstevel@tonic-gatecan import the certificate using the certificate import wizard.
3680Sstevel@tonic-gate
3690Sstevel@tonic-gateYou can convert a certificate to DER form using the command:
3700Sstevel@tonic-gate
3710Sstevel@tonic-gateopenssl x509 -in ca.pem -outform DER -out ca.der
3720Sstevel@tonic-gate
3730Sstevel@tonic-gateOccasionally someone suggests using a command such as:
3740Sstevel@tonic-gate
3750Sstevel@tonic-gateopenssl pkcs12 -export -out cacert.p12 -in cacert.pem -inkey cakey.pem
3760Sstevel@tonic-gate
3770Sstevel@tonic-gateDO NOT DO THIS! This command will give away your CAs private key and
3780Sstevel@tonic-gatereduces its security to zero: allowing anyone to forge certificates in
3790Sstevel@tonic-gatewhatever name they choose.
3800Sstevel@tonic-gate
3810Sstevel@tonic-gate* Why is OpenSSL x509 DN output not conformant to RFC2253?
3820Sstevel@tonic-gate
3830Sstevel@tonic-gateThe ways to print out the oneline format of the DN (Distinguished Name) have
3840Sstevel@tonic-gatebeen extended in version 0.9.7 of OpenSSL. Using the new X509_NAME_print_ex()
3850Sstevel@tonic-gateinterface, the "-nameopt" option could be introduded. See the manual
3860Sstevel@tonic-gatepage of the "openssl x509" commandline tool for details. The old behaviour
3870Sstevel@tonic-gatehas however been left as default for the sake of compatibility.
3880Sstevel@tonic-gate
3890Sstevel@tonic-gate[BUILD] =======================================================================
3900Sstevel@tonic-gate
3910Sstevel@tonic-gate* Why does the linker complain about undefined symbols?
3920Sstevel@tonic-gate
3930Sstevel@tonic-gateMaybe the compilation was interrupted, and make doesn't notice that
3940Sstevel@tonic-gatesomething is missing.  Run "make clean; make".
3950Sstevel@tonic-gate
3960Sstevel@tonic-gateIf you used ./Configure instead of ./config, make sure that you
3970Sstevel@tonic-gateselected the right target.  File formats may differ slightly between
3980Sstevel@tonic-gateOS versions (for example sparcv8/sparcv9, or a.out/elf).
3990Sstevel@tonic-gate
4000Sstevel@tonic-gateIn case you get errors about the following symbols, use the config
4010Sstevel@tonic-gateoption "no-asm", as described in INSTALL:
4020Sstevel@tonic-gate
4030Sstevel@tonic-gate BF_cbc_encrypt, BF_decrypt, BF_encrypt, CAST_cbc_encrypt,
4040Sstevel@tonic-gate CAST_decrypt, CAST_encrypt, RC4, RC5_32_cbc_encrypt, RC5_32_decrypt,
4050Sstevel@tonic-gate RC5_32_encrypt, bn_add_words, bn_div_words, bn_mul_add_words,
4060Sstevel@tonic-gate bn_mul_comba4, bn_mul_comba8, bn_mul_words, bn_sqr_comba4,
4070Sstevel@tonic-gate bn_sqr_comba8, bn_sqr_words, bn_sub_words, des_decrypt3,
4080Sstevel@tonic-gate des_ede3_cbc_encrypt, des_encrypt, des_encrypt2, des_encrypt3,
4090Sstevel@tonic-gate des_ncbc_encrypt, md5_block_asm_host_order, sha1_block_asm_data_order
4100Sstevel@tonic-gate
4110Sstevel@tonic-gateIf none of these helps, you may want to try using the current snapshot.
4120Sstevel@tonic-gateIf the problem persists, please submit a bug report.
4130Sstevel@tonic-gate
4140Sstevel@tonic-gate
4150Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: command not found"?
4160Sstevel@tonic-gate
4170Sstevel@tonic-gateYou didn't install "bc", the Unix calculator.  If you want to run the
4180Sstevel@tonic-gatetests, get GNU bc from ftp://ftp.gnu.org or from your OS distributor.
4190Sstevel@tonic-gate
4200Sstevel@tonic-gate
4210Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: 1 no implemented"?
4220Sstevel@tonic-gate
4230Sstevel@tonic-gateOn some SCO installations or versions, bc has a bug that gets triggered
4240Sstevel@tonic-gatewhen you run the test suite (using "make test").  The message returned is
4250Sstevel@tonic-gate"bc: 1 not implemented".
4260Sstevel@tonic-gate
4270Sstevel@tonic-gateThe best way to deal with this is to find another implementation of bc
4280Sstevel@tonic-gateand compile/install it.  GNU bc (see http://www.gnu.org/software/software.html
4290Sstevel@tonic-gatefor download instructions) can be safely used, for example.
4300Sstevel@tonic-gate
4310Sstevel@tonic-gate
4320Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: stack empty"?
4330Sstevel@tonic-gate
4340Sstevel@tonic-gateOn some DG/ux versions, bc seems to have a too small stack for calculations
4350Sstevel@tonic-gatethat the OpenSSL bntest throws at it.  This gets triggered when you run the
4360Sstevel@tonic-gatetest suite (using "make test").  The message returned is "bc: stack empty".
4370Sstevel@tonic-gate
4380Sstevel@tonic-gateThe best way to deal with this is to find another implementation of bc
4390Sstevel@tonic-gateand compile/install it.  GNU bc (see http://www.gnu.org/software/software.html
4400Sstevel@tonic-gatefor download instructions) can be safely used, for example.
4410Sstevel@tonic-gate
4420Sstevel@tonic-gate
4430Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Alpha Tru64 Unix?
4440Sstevel@tonic-gate
4450Sstevel@tonic-gateOn some Alpha installations running Tru64 Unix and Compaq C, the compilation
4460Sstevel@tonic-gateof crypto/sha/sha_dgst.c fails with the message 'Fatal:  Insufficient virtual
4470Sstevel@tonic-gatememory to continue compilation.'  As far as the tests have shown, this may be
4480Sstevel@tonic-gatea compiler bug.  What happens is that it eats up a lot of resident memory
4490Sstevel@tonic-gateto build something, probably a table.  The problem is clearly in the
4500Sstevel@tonic-gateoptimization code, because if one eliminates optimization completely (-O0),
4510Sstevel@tonic-gatethe compilation goes through (and the compiler consumes about 2MB of resident
4520Sstevel@tonic-gatememory instead of 240MB or whatever one's limit is currently).
4530Sstevel@tonic-gate
4540Sstevel@tonic-gateThere are three options to solve this problem:
4550Sstevel@tonic-gate
4560Sstevel@tonic-gate1. set your current data segment size soft limit higher.  Experience shows
4570Sstevel@tonic-gatethat about 241000 kbytes seems to be enough on an AlphaServer DS10.  You do
4580Sstevel@tonic-gatethis with the command 'ulimit -Sd nnnnnn', where 'nnnnnn' is the number of
4590Sstevel@tonic-gatekbytes to set the limit to.
4600Sstevel@tonic-gate
4610Sstevel@tonic-gate2. If you have a hard limit that is lower than what you need and you can't
4620Sstevel@tonic-gateget it changed, you can compile all of OpenSSL with -O0 as optimization
4630Sstevel@tonic-gatelevel.  This is however not a very nice thing to do for those who expect to
4640Sstevel@tonic-gateget the best result from OpenSSL.  A bit more complicated solution is the
4650Sstevel@tonic-gatefollowing:
4660Sstevel@tonic-gate
4670Sstevel@tonic-gate----- snip:start -----
4680Sstevel@tonic-gate  make DIRS=crypto SDIRS=sha "`grep '^CFLAG=' Makefile.ssl | \
4690Sstevel@tonic-gate       sed -e 's/ -O[0-9] / -O0 /'`"
4700Sstevel@tonic-gate  rm `ls crypto/*.o crypto/sha/*.o | grep -v 'sha_dgst\.o'`
4710Sstevel@tonic-gate  make
4720Sstevel@tonic-gate----- snip:end -----
4730Sstevel@tonic-gate
4740Sstevel@tonic-gateThis will only compile sha_dgst.c with -O0, the rest with the optimization
4750Sstevel@tonic-gatelevel chosen by the configuration process.  When the above is done, do the
4760Sstevel@tonic-gatetest and installation and you're set.
4770Sstevel@tonic-gate
478*2139Sjp1619483. Reconfigure the toolkit with no-sha0 option to leave out SHA0. It
479*2139Sjp161948should not be used and is not used in SSL/TLS nor any other recognized
480*2139Sjp161948protocol in either case.
481*2139Sjp161948
4820Sstevel@tonic-gate
4830Sstevel@tonic-gate* Why does the OpenSSL compilation fail with "ar: command not found"?
4840Sstevel@tonic-gate
4850Sstevel@tonic-gateGetting this message is quite usual on Solaris 2, because Sun has hidden
4860Sstevel@tonic-gateaway 'ar' and other development commands in directories that aren't in
4870Sstevel@tonic-gate$PATH by default.  One of those directories is '/usr/ccs/bin'.  The
4880Sstevel@tonic-gatequickest way to fix this is to do the following (it assumes you use sh
4890Sstevel@tonic-gateor any sh-compatible shell):
4900Sstevel@tonic-gate
4910Sstevel@tonic-gate----- snip:start -----
4920Sstevel@tonic-gate  PATH=${PATH}:/usr/ccs/bin; export PATH
4930Sstevel@tonic-gate----- snip:end -----
4940Sstevel@tonic-gate
4950Sstevel@tonic-gateand then redo the compilation.  What you should really do is make sure
4960Sstevel@tonic-gate'/usr/ccs/bin' is permanently in your $PATH, for example through your
4970Sstevel@tonic-gate'.profile' (again, assuming you use a sh-compatible shell).
4980Sstevel@tonic-gate
4990Sstevel@tonic-gate
5000Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Win32 with VC++?
5010Sstevel@tonic-gate
5020Sstevel@tonic-gateSometimes, you may get reports from VC++ command line (cl) that it
5030Sstevel@tonic-gatecan't find standard include files like stdio.h and other weirdnesses.
5040Sstevel@tonic-gateOne possible cause is that the environment isn't correctly set up.
5050Sstevel@tonic-gateTo solve that problem for VC++ versions up to 6, one should run
5060Sstevel@tonic-gateVCVARS32.BAT which is found in the 'bin' subdirectory of the VC++
5070Sstevel@tonic-gateinstallation directory (somewhere under 'Program Files').  For VC++
5080Sstevel@tonic-gateversion 7 (and up?), which is also called VS.NET, the file is called
5090Sstevel@tonic-gateVSVARS32.BAT instead.
5100Sstevel@tonic-gateThis needs to be done prior to running NMAKE, and the changes are only
5110Sstevel@tonic-gatevalid for the current DOS session.
5120Sstevel@tonic-gate
5130Sstevel@tonic-gate
5140Sstevel@tonic-gate* What is special about OpenSSL on Redhat?
5150Sstevel@tonic-gate
5160Sstevel@tonic-gateRed Hat Linux (release 7.0 and later) include a preinstalled limited
5170Sstevel@tonic-gateversion of OpenSSL. For patent reasons, support for IDEA, RC5 and MDC2
5180Sstevel@tonic-gateis disabled in this version. The same may apply to other Linux distributions.
5190Sstevel@tonic-gateUsers may therefore wish to install more or all of the features left out.
5200Sstevel@tonic-gate
5210Sstevel@tonic-gateTo do this you MUST ensure that you do not overwrite the openssl that is in
5220Sstevel@tonic-gate/usr/bin on your Red Hat machine. Several packages depend on this file,
5230Sstevel@tonic-gateincluding sendmail and ssh. /usr/local/bin is a good alternative choice. The
5240Sstevel@tonic-gatelibraries that come with Red Hat 7.0 onwards have different names and so are
5250Sstevel@tonic-gatenot affected. (eg For Red Hat 7.2 they are /lib/libssl.so.0.9.6b and
5260Sstevel@tonic-gate/lib/libcrypto.so.0.9.6b with symlinks /lib/libssl.so.2 and
5270Sstevel@tonic-gate/lib/libcrypto.so.2 respectively).
5280Sstevel@tonic-gate
5290Sstevel@tonic-gatePlease note that we have been advised by Red Hat attempting to recompile the
5300Sstevel@tonic-gateopenssl rpm with all the cryptography enabled will not work. All other
5310Sstevel@tonic-gatepackages depend on the original Red Hat supplied openssl package. It is also
5320Sstevel@tonic-gateworth noting that due to the way Red Hat supplies its packages, updates to
5330Sstevel@tonic-gateopenssl on each distribution never change the package version, only the
5340Sstevel@tonic-gatebuild number. For example, on Red Hat 7.1, the latest openssl package has
5350Sstevel@tonic-gateversion number 0.9.6 and build number 9 even though it contains all the
5360Sstevel@tonic-gaterelevant updates in packages up to and including 0.9.6b.
5370Sstevel@tonic-gate
5380Sstevel@tonic-gateA possible way around this is to persuade Red Hat to produce a non-US
5390Sstevel@tonic-gateversion of Red Hat Linux.
5400Sstevel@tonic-gate
5410Sstevel@tonic-gateFYI: Patent numbers and expiry dates of US patents:
5420Sstevel@tonic-gateMDC-2: 4,908,861 13/03/2007
5430Sstevel@tonic-gateIDEA:  5,214,703 25/05/2010
5440Sstevel@tonic-gateRC5:   5,724,428 03/03/2015
5450Sstevel@tonic-gate
5460Sstevel@tonic-gate
5470Sstevel@tonic-gate* Why does the OpenSSL compilation fail on MacOS X?
5480Sstevel@tonic-gate
5490Sstevel@tonic-gateIf the failure happens when trying to build the "openssl" binary, with
5500Sstevel@tonic-gatea large number of undefined symbols, it's very probable that you have
5510Sstevel@tonic-gateOpenSSL 0.9.6b delivered with the operating system (you can find out by
5520Sstevel@tonic-gaterunning '/usr/bin/openssl version') and that you were trying to build
5530Sstevel@tonic-gateOpenSSL 0.9.7 or newer.  The problem is that the loader ('ld') in
5540Sstevel@tonic-gateMacOS X has a misfeature that's quite difficult to go around.
5550Sstevel@tonic-gateLook in the file PROBLEMS for a more detailed explanation and for possible
5560Sstevel@tonic-gatesolutions.
5570Sstevel@tonic-gate
5580Sstevel@tonic-gate
5590Sstevel@tonic-gate* Why does the OpenSSL test suite fail on MacOS X?
5600Sstevel@tonic-gate
5610Sstevel@tonic-gateIf the failure happens when running 'make test' and the RC4 test fails,
5620Sstevel@tonic-gateit's very probable that you have OpenSSL 0.9.6b delivered with the
5630Sstevel@tonic-gateoperating system (you can find out by running '/usr/bin/openssl version')
5640Sstevel@tonic-gateand that you were trying to build OpenSSL 0.9.6d.  The problem is that
5650Sstevel@tonic-gatethe loader ('ld') in MacOS X has a misfeature that's quite difficult to
5660Sstevel@tonic-gatego around and has linked the programs "openssl" and the test programs
5670Sstevel@tonic-gatewith /usr/lib/libcrypto.dylib and /usr/lib/libssl.dylib instead of the
5680Sstevel@tonic-gatelibraries you just built.
5690Sstevel@tonic-gateLook in the file PROBLEMS for a more detailed explanation and for possible
5700Sstevel@tonic-gatesolutions.
5710Sstevel@tonic-gate
5720Sstevel@tonic-gate* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]?
5730Sstevel@tonic-gate
5740Sstevel@tonic-gateFailure in BN_sqr test is most likely caused by a failure to configure the
5750Sstevel@tonic-gatetoolkit for current platform or lack of support for the platform in question.
5760Sstevel@tonic-gateRun './config -t' and './apps/openssl version -p'. Do these platform
5770Sstevel@tonic-gateidentifiers match? If they don't, then you most likely failed to run
5780Sstevel@tonic-gate./config and you're hereby advised to do so before filing a bug report.
5790Sstevel@tonic-gateIf ./config itself fails to run, then it's most likely problem with your
5800Sstevel@tonic-gatelocal environment and you should turn to your system administrator (or
5810Sstevel@tonic-gatesimilar). If identifiers match (and/or no alternative identifier is
5820Sstevel@tonic-gatesuggested by ./config script), then the platform is unsupported. There might
5830Sstevel@tonic-gateor might not be a workaround. Most notably on SPARC64 platforms with GNU
5840Sstevel@tonic-gateC compiler you should be able to produce a working build by running
5850Sstevel@tonic-gate'./config -m32'. I understand that -m32 might not be what you want/need,
5860Sstevel@tonic-gatebut the build should be operational. For further details turn to
5870Sstevel@tonic-gate<openssl-dev@openssl.org>.
5880Sstevel@tonic-gate
5890Sstevel@tonic-gate* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"?
5900Sstevel@tonic-gate
5910Sstevel@tonic-gateAs of 0.9.7 assembler routines were overhauled for position independence
5920Sstevel@tonic-gateof the machine code, which is essential for shared library support. For
5930Sstevel@tonic-gatesome reason OpenBSD is equipped with an out-of-date GNU assembler which
5940Sstevel@tonic-gatefinds the new code offensive. To work around the problem, configure with
5950Sstevel@tonic-gateno-asm (and sacrifice a great deal of performance) or patch your assembler
5960Sstevel@tonic-gateaccording to <URL: http://www.openssl.org/~appro/gas-1.92.3.OpenBSD.patch>.
5970Sstevel@tonic-gateFor your convenience a pre-compiled replacement binary is provided at
5980Sstevel@tonic-gate<URL: http://www.openssl.org/~appro/gas-1.92.3.static.aout.bin>.
5990Sstevel@tonic-gateReportedly elder *BSD a.out platforms also suffer from this problem and
6000Sstevel@tonic-gateremedy should be same. Provided binary is statically linked and should be
6010Sstevel@tonic-gateworking across wider range of *BSD branches, not just OpenBSD.
6020Sstevel@tonic-gate
603*2139Sjp161948* Why does the OpenSSL test suite fail in sha512t on x86 CPU?
604*2139Sjp161948
605*2139Sjp161948If the test program in question fails withs SIGILL, Illegal Instruction
606*2139Sjp161948exception, then you more than likely to run SSE2-capable CPU, such as
607*2139Sjp161948Intel P4, under control of kernel which does not support SSE2
608*2139Sjp161948instruction extentions. See accompanying INSTALL file and
609*2139Sjp161948OPENSSL_ia32cap(3) documentation page for further information.
610*2139Sjp161948
611*2139Sjp161948* Why does compiler fail to compile sha512.c?
612*2139Sjp161948
613*2139Sjp161948OpenSSL SHA-512 implementation depends on compiler support for 64-bit
614*2139Sjp161948integer type. Few elder compilers [ULTRIX cc, SCO compiler to mention a
615*2139Sjp161948couple] lack support for this and therefore are incapable of compiling
616*2139Sjp161948the module in question. The recommendation is to disable SHA-512 by
617*2139Sjp161948adding no-sha512 to ./config [or ./Configure] command line. Another
618*2139Sjp161948possible alternative might be to switch to GCC.
619*2139Sjp161948
6200Sstevel@tonic-gate[PROG] ========================================================================
6210Sstevel@tonic-gate
6220Sstevel@tonic-gate* Is OpenSSL thread-safe?
6230Sstevel@tonic-gate
6240Sstevel@tonic-gateYes (with limitations: an SSL connection may not concurrently be used
6250Sstevel@tonic-gateby multiple threads).  On Windows and many Unix systems, OpenSSL
6260Sstevel@tonic-gateautomatically uses the multi-threaded versions of the standard
6270Sstevel@tonic-gatelibraries.  If your platform is not one of these, consult the INSTALL
6280Sstevel@tonic-gatefile.
6290Sstevel@tonic-gate
6300Sstevel@tonic-gateMulti-threaded applications must provide two callback functions to
6310Sstevel@tonic-gateOpenSSL.  This is described in the threads(3) manpage.
6320Sstevel@tonic-gate
6330Sstevel@tonic-gate
6340Sstevel@tonic-gate* I've compiled a program under Windows and it crashes: why?
6350Sstevel@tonic-gate
6360Sstevel@tonic-gateThis is usually because you've missed the comment in INSTALL.W32.
6370Sstevel@tonic-gateYour application must link against the same version of the Win32
6380Sstevel@tonic-gateC-Runtime against which your openssl libraries were linked.  The
6390Sstevel@tonic-gatedefault version for OpenSSL is /MD - "Multithreaded DLL".
6400Sstevel@tonic-gate
6410Sstevel@tonic-gateIf you are using Microsoft Visual C++'s IDE (Visual Studio), in
6420Sstevel@tonic-gatemany cases, your new project most likely defaulted to "Debug
6430Sstevel@tonic-gateSinglethreaded" - /ML.  This is NOT interchangeable with /MD and your
6440Sstevel@tonic-gateprogram will crash, typically on the first BIO related read or write
6450Sstevel@tonic-gateoperation.
6460Sstevel@tonic-gate
6470Sstevel@tonic-gateFor each of the six possible link stage configurations within Win32,
6480Sstevel@tonic-gateyour application must link  against the same by which OpenSSL was
6490Sstevel@tonic-gatebuilt.  If you are using MS Visual C++ (Studio) this can be changed
6500Sstevel@tonic-gateby:
6510Sstevel@tonic-gate
6520Sstevel@tonic-gate1.  Select Settings... from the Project Menu.
6530Sstevel@tonic-gate2.  Select the C/C++ Tab.
6540Sstevel@tonic-gate3.  Select "Code Generation from the "Category" drop down list box
6550Sstevel@tonic-gate4.  Select the Appropriate library (see table below) from the "Use
6560Sstevel@tonic-gate    run-time library" drop down list box.  Perform this step for both
6570Sstevel@tonic-gate    your debug and release versions of your application (look at the
6580Sstevel@tonic-gate    top left of the settings panel to change between the two)
6590Sstevel@tonic-gate
6600Sstevel@tonic-gate    Single Threaded           /ML        -  MS VC++ often defaults to
6610Sstevel@tonic-gate                                            this for the release
6620Sstevel@tonic-gate                                            version of a new project.
6630Sstevel@tonic-gate    Debug Single Threaded     /MLd       -  MS VC++ often defaults to
6640Sstevel@tonic-gate                                            this for the debug version
6650Sstevel@tonic-gate                                            of a new project.
6660Sstevel@tonic-gate    Multithreaded             /MT
6670Sstevel@tonic-gate    Debug Multithreaded       /MTd
6680Sstevel@tonic-gate    Multithreaded DLL         /MD        -  OpenSSL defaults to this.
6690Sstevel@tonic-gate    Debug Multithreaded DLL   /MDd
6700Sstevel@tonic-gate
6710Sstevel@tonic-gateNote that debug and release libraries are NOT interchangeable.  If you
6720Sstevel@tonic-gatebuilt OpenSSL with /MD your application must use /MD and cannot use /MDd.
6730Sstevel@tonic-gate
674*2139Sjp161948As per 0.9.8 the above limitation is eliminated for .DLLs. OpenSSL
675*2139Sjp161948.DLLs compiled with some specific run-time option [we recommend the
676*2139Sjp161948default /MD] can be deployed with application compiled with different
677*2139Sjp161948option or even different compiler. But there is a catch! Instead of
678*2139Sjp161948re-compiling OpenSSL toolkit, as you would have to with prior versions,
679*2139Sjp161948you have to compile small C snippet with compiler and/or options of
680*2139Sjp161948your choice. The snippet gets installed as
681*2139Sjp161948<install-root>/include/openssl/applink.c and should be either added to
682*2139Sjp161948your project or simply #include-d in one [and only one] of your source
683*2139Sjp161948files. Failure to do either manifests itself as fatal "no
684*2139Sjp161948OPENSSL_Applink" error.
6850Sstevel@tonic-gate
6860Sstevel@tonic-gate* How do I read or write a DER encoded buffer using the ASN1 functions?
6870Sstevel@tonic-gate
6880Sstevel@tonic-gateYou have two options. You can either use a memory BIO in conjunction
689*2139Sjp161948with the i2d_*_bio() or d2i_*_bio() functions or you can use the
690*2139Sjp161948i2d_*(), d2i_*() functions directly. Since these are often the
6910Sstevel@tonic-gatecause of grief here are some code fragments using PKCS7 as an example:
6920Sstevel@tonic-gate
693*2139Sjp161948 unsigned char *buf, *p;
694*2139Sjp161948 int len;
6950Sstevel@tonic-gate
696*2139Sjp161948 len = i2d_PKCS7(p7, NULL);
697*2139Sjp161948 buf = OPENSSL_malloc(len); /* or Malloc, error checking omitted */
698*2139Sjp161948 p = buf;
699*2139Sjp161948 i2d_PKCS7(p7, &p);
7000Sstevel@tonic-gate
7010Sstevel@tonic-gateAt this point buf contains the len bytes of the DER encoding of
7020Sstevel@tonic-gatep7.
7030Sstevel@tonic-gate
7040Sstevel@tonic-gateThe opposite assumes we already have len bytes in buf:
7050Sstevel@tonic-gate
706*2139Sjp161948 unsigned char *p;
707*2139Sjp161948 p = buf;
708*2139Sjp161948 p7 = d2i_PKCS7(NULL, &p, len);
7090Sstevel@tonic-gate
7100Sstevel@tonic-gateAt this point p7 contains a valid PKCS7 structure of NULL if an error
7110Sstevel@tonic-gateoccurred. If an error occurred ERR_print_errors(bio) should give more
7120Sstevel@tonic-gateinformation.
7130Sstevel@tonic-gate
7140Sstevel@tonic-gateThe reason for the temporary variable 'p' is that the ASN1 functions
7150Sstevel@tonic-gateincrement the passed pointer so it is ready to read or write the next
7160Sstevel@tonic-gatestructure. This is often a cause of problems: without the temporary
7170Sstevel@tonic-gatevariable the buffer pointer is changed to point just after the data
7180Sstevel@tonic-gatethat has been read or written. This may well be uninitialized data
7190Sstevel@tonic-gateand attempts to free the buffer will have unpredictable results
7200Sstevel@tonic-gatebecause it no longer points to the same address.
7210Sstevel@tonic-gate
7220Sstevel@tonic-gate
723*2139Sjp161948* OpenSSL uses DER but I need BER format: does OpenSSL support BER?
724*2139Sjp161948
725*2139Sjp161948The short answer is yes, because DER is a special case of BER and OpenSSL
726*2139Sjp161948ASN1 decoders can process BER.
727*2139Sjp161948
728*2139Sjp161948The longer answer is that ASN1 structures can be encoded in a number of
729*2139Sjp161948different ways. One set of ways is the Basic Encoding Rules (BER) with various
730*2139Sjp161948permissible encodings. A restriction of BER is the Distinguished Encoding
731*2139Sjp161948Rules (DER): these uniquely specify how a given structure is encoded.
732*2139Sjp161948
733*2139Sjp161948Therefore, because DER is a special case of BER, DER is an acceptable encoding
734*2139Sjp161948for BER.
735*2139Sjp161948
736*2139Sjp161948
7370Sstevel@tonic-gate* I've tried using <M_some_evil_pkcs12_macro> and I get errors why?
7380Sstevel@tonic-gate
7390Sstevel@tonic-gateThis usually happens when you try compiling something using the PKCS#12
7400Sstevel@tonic-gatemacros with a C++ compiler. There is hardly ever any need to use the
7410Sstevel@tonic-gatePKCS#12 macros in a program, it is much easier to parse and create
7420Sstevel@tonic-gatePKCS#12 files using the PKCS12_parse() and PKCS12_create() functions
7430Sstevel@tonic-gatedocumented in doc/openssl.txt and with examples in demos/pkcs12. The
7440Sstevel@tonic-gate'pkcs12' application has to use the macros because it prints out
7450Sstevel@tonic-gatedebugging information.
7460Sstevel@tonic-gate
7470Sstevel@tonic-gate
7480Sstevel@tonic-gate* I've called <some function> and it fails, why?
7490Sstevel@tonic-gate
7500Sstevel@tonic-gateBefore submitting a report or asking in one of the mailing lists, you
7510Sstevel@tonic-gateshould try to determine the cause. In particular, you should call
7520Sstevel@tonic-gateERR_print_errors() or ERR_print_errors_fp() after the failed call
7530Sstevel@tonic-gateand see if the message helps. Note that the problem may occur earlier
7540Sstevel@tonic-gatethan you think -- you should check for errors after every call where
7550Sstevel@tonic-gateit is possible, otherwise the actual problem may be hidden because
7560Sstevel@tonic-gatesome OpenSSL functions clear the error state.
7570Sstevel@tonic-gate
7580Sstevel@tonic-gate
7590Sstevel@tonic-gate* I just get a load of numbers for the error output, what do they mean?
7600Sstevel@tonic-gate
7610Sstevel@tonic-gateThe actual format is described in the ERR_print_errors() manual page.
7620Sstevel@tonic-gateYou should call the function ERR_load_crypto_strings() before hand and
7630Sstevel@tonic-gatethe message will be output in text form. If you can't do this (for example
7640Sstevel@tonic-gateit is a pre-compiled binary) you can use the errstr utility on the error
7650Sstevel@tonic-gatecode itself (the hex digits after the second colon).
7660Sstevel@tonic-gate
7670Sstevel@tonic-gate
7680Sstevel@tonic-gate* Why do I get errors about unknown algorithms?
7690Sstevel@tonic-gate
7700Sstevel@tonic-gateThis can happen under several circumstances such as reading in an
7710Sstevel@tonic-gateencrypted private key or attempting to decrypt a PKCS#12 file. The cause
7720Sstevel@tonic-gateis forgetting to load OpenSSL's table of algorithms with
7730Sstevel@tonic-gateOpenSSL_add_all_algorithms(). See the manual page for more information.
7740Sstevel@tonic-gate
7750Sstevel@tonic-gate
7760Sstevel@tonic-gate* Why can't the OpenSSH configure script detect OpenSSL?
7770Sstevel@tonic-gate
7780Sstevel@tonic-gateSeveral reasons for problems with the automatic detection exist.
7790Sstevel@tonic-gateOpenSSH requires at least version 0.9.5a of the OpenSSL libraries.
7800Sstevel@tonic-gateSometimes the distribution has installed an older version in the system
7810Sstevel@tonic-gatelocations that is detected instead of a new one installed. The OpenSSL
7820Sstevel@tonic-gatelibrary might have been compiled for another CPU or another mode (32/64 bits).
7830Sstevel@tonic-gatePermissions might be wrong.
7840Sstevel@tonic-gate
7850Sstevel@tonic-gateThe general answer is to check the config.log file generated when running
7860Sstevel@tonic-gatethe OpenSSH configure script. It should contain the detailed information
7870Sstevel@tonic-gateon why the OpenSSL library was not detected or considered incompatible.
7880Sstevel@tonic-gate
7890Sstevel@tonic-gate
7900Sstevel@tonic-gate* Can I use OpenSSL's SSL library with non-blocking I/O?
7910Sstevel@tonic-gate
7920Sstevel@tonic-gateYes; make sure to read the SSL_get_error(3) manual page!
7930Sstevel@tonic-gate
7940Sstevel@tonic-gateA pitfall to avoid: Don't assume that SSL_read() will just read from
7950Sstevel@tonic-gatethe underlying transport or that SSL_write() will just write to it --
7960Sstevel@tonic-gateit is also possible that SSL_write() cannot do any useful work until
7970Sstevel@tonic-gatethere is data to read, or that SSL_read() cannot do anything until it
7980Sstevel@tonic-gateis possible to send data.  One reason for this is that the peer may
7990Sstevel@tonic-gaterequest a new TLS/SSL handshake at any time during the protocol,
8000Sstevel@tonic-gaterequiring a bi-directional message exchange; both SSL_read() and
8010Sstevel@tonic-gateSSL_write() will try to continue any pending handshake.
8020Sstevel@tonic-gate
8030Sstevel@tonic-gate
8040Sstevel@tonic-gate* Why doesn't my server application receive a client certificate?
8050Sstevel@tonic-gate
8060Sstevel@tonic-gateDue to the TLS protocol definition, a client will only send a certificate,
8070Sstevel@tonic-gateif explicitly asked by the server. Use the SSL_VERIFY_PEER flag of the
8080Sstevel@tonic-gateSSL_CTX_set_verify() function to enable the use of client certificates.
8090Sstevel@tonic-gate
8100Sstevel@tonic-gate
8110Sstevel@tonic-gate* Why does compilation fail due to an undefined symbol NID_uniqueIdentifier?
8120Sstevel@tonic-gate
8130Sstevel@tonic-gateFor OpenSSL 0.9.7 the OID table was extended and corrected. In earlier
8140Sstevel@tonic-gateversions, uniqueIdentifier was incorrectly used for X.509 certificates.
8150Sstevel@tonic-gateThe correct name according to RFC2256 (LDAP) is x500UniqueIdentifier.
8160Sstevel@tonic-gateChange your code to use the new name when compiling against OpenSSL 0.9.7.
8170Sstevel@tonic-gate
8180Sstevel@tonic-gate
819*2139Sjp161948* I think I've detected a memory leak, is this a bug?
820*2139Sjp161948
821*2139Sjp161948In most cases the cause of an apparent memory leak is an OpenSSL internal table
822*2139Sjp161948that is allocated when an application starts up. Since such tables do not grow
823*2139Sjp161948in size over time they are harmless.
824*2139Sjp161948
825*2139Sjp161948These internal tables can be freed up when an application closes using various
826*2139Sjp161948functions.  Currently these include following:
827*2139Sjp161948
828*2139Sjp161948Thread-local cleanup functions:
829*2139Sjp161948
830*2139Sjp161948  ERR_remove_state()
831*2139Sjp161948
832*2139Sjp161948Application-global cleanup functions that are aware of usage (and therefore
833*2139Sjp161948thread-safe):
834*2139Sjp161948
835*2139Sjp161948  ENGINE_cleanup() and CONF_modules_unload()
836*2139Sjp161948
837*2139Sjp161948"Brutal" (thread-unsafe) Application-global cleanup functions:
838*2139Sjp161948
839*2139Sjp161948  ERR_free_strings(), EVP_cleanup() and CRYPTO_cleanup_all_ex_data().
840*2139Sjp161948
841*2139Sjp161948
8420Sstevel@tonic-gate===============================================================================
8430Sstevel@tonic-gate
844