1*0Sstevel@tonic-gateOpenSSL - Frequently Asked Questions 2*0Sstevel@tonic-gate-------------------------------------- 3*0Sstevel@tonic-gate 4*0Sstevel@tonic-gate[MISC] Miscellaneous questions 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate* Which is the current version of OpenSSL? 7*0Sstevel@tonic-gate* Where is the documentation? 8*0Sstevel@tonic-gate* How can I contact the OpenSSL developers? 9*0Sstevel@tonic-gate* Where can I get a compiled version of OpenSSL? 10*0Sstevel@tonic-gate* Why aren't tools like 'autoconf' and 'libtool' used? 11*0Sstevel@tonic-gate* What is an 'engine' version? 12*0Sstevel@tonic-gate* How do I check the authenticity of the OpenSSL distribution? 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate[LEGAL] Legal questions 15*0Sstevel@tonic-gate 16*0Sstevel@tonic-gate* Do I need patent licenses to use OpenSSL? 17*0Sstevel@tonic-gate* Can I use OpenSSL with GPL software? 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gate[USER] Questions on using the OpenSSL applications 20*0Sstevel@tonic-gate 21*0Sstevel@tonic-gate* Why do I get a "PRNG not seeded" error message? 22*0Sstevel@tonic-gate* Why do I get an "unable to write 'random state'" error message? 23*0Sstevel@tonic-gate* How do I create certificates or certificate requests? 24*0Sstevel@tonic-gate* Why can't I create certificate requests? 25*0Sstevel@tonic-gate* Why does <SSL program> fail with a certificate verify error? 26*0Sstevel@tonic-gate* Why can I only use weak ciphers when I connect to a server using OpenSSL? 27*0Sstevel@tonic-gate* How can I create DSA certificates? 28*0Sstevel@tonic-gate* Why can't I make an SSL connection using a DSA certificate? 29*0Sstevel@tonic-gate* How can I remove the passphrase on a private key? 30*0Sstevel@tonic-gate* Why can't I use OpenSSL certificates with SSL client authentication? 31*0Sstevel@tonic-gate* Why does my browser give a warning about a mismatched hostname? 32*0Sstevel@tonic-gate* How do I install a CA certificate into a browser? 33*0Sstevel@tonic-gate* Why is OpenSSL x509 DN output not conformant to RFC2253? 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate[BUILD] Questions about building and testing OpenSSL 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate* Why does the linker complain about undefined symbols? 38*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: command not found"? 39*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: 1 no implemented"? 40*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: stack empty"? 41*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Alpha Tru64 Unix? 42*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail with "ar: command not found"? 43*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Win32 with VC++? 44*0Sstevel@tonic-gate* What is special about OpenSSL on Redhat? 45*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on MacOS X? 46*0Sstevel@tonic-gate* Why does the OpenSSL test suite fail on MacOS X? 47*0Sstevel@tonic-gate* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]? 48*0Sstevel@tonic-gate* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"? 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate[PROG] Questions about programming with OpenSSL 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate* Is OpenSSL thread-safe? 53*0Sstevel@tonic-gate* I've compiled a program under Windows and it crashes: why? 54*0Sstevel@tonic-gate* How do I read or write a DER encoded buffer using the ASN1 functions? 55*0Sstevel@tonic-gate* I've tried using <M_some_evil_pkcs12_macro> and I get errors why? 56*0Sstevel@tonic-gate* I've called <some function> and it fails, why? 57*0Sstevel@tonic-gate* I just get a load of numbers for the error output, what do they mean? 58*0Sstevel@tonic-gate* Why do I get errors about unknown algorithms? 59*0Sstevel@tonic-gate* Why can't the OpenSSH configure script detect OpenSSL? 60*0Sstevel@tonic-gate* Can I use OpenSSL's SSL library with non-blocking I/O? 61*0Sstevel@tonic-gate* Why doesn't my server application receive a client certificate? 62*0Sstevel@tonic-gate* Why does compilation fail due to an undefined symbol NID_uniqueIdentifier? 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate=============================================================================== 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate[MISC] ======================================================================== 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate* Which is the current version of OpenSSL? 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gateThe current version is available from <URL: http://www.openssl.org>. 71*0Sstevel@tonic-gateOpenSSL 0.9.7d was released on March 17, 2004. 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gateIn addition to the current stable release, you can also access daily 74*0Sstevel@tonic-gatesnapshots of the OpenSSL development version at <URL: 75*0Sstevel@tonic-gateftp://ftp.openssl.org/snapshot/>, or get it by anonymous CVS access. 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate* Where is the documentation? 79*0Sstevel@tonic-gate 80*0Sstevel@tonic-gateOpenSSL is a library that provides cryptographic functionality to 81*0Sstevel@tonic-gateapplications such as secure web servers. Be sure to read the 82*0Sstevel@tonic-gatedocumentation of the application you want to use. The INSTALL file 83*0Sstevel@tonic-gateexplains how to install this library. 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gateOpenSSL includes a command line utility that can be used to perform a 86*0Sstevel@tonic-gatevariety of cryptographic functions. It is described in the openssl(1) 87*0Sstevel@tonic-gatemanpage. Documentation for developers is currently being written. A 88*0Sstevel@tonic-gatefew manual pages already are available; overviews over libcrypto and 89*0Sstevel@tonic-gatelibssl are given in the crypto(3) and ssl(3) manpages. 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gateThe OpenSSL manpages are installed in /usr/local/ssl/man/ (or a 92*0Sstevel@tonic-gatedifferent directory if you specified one as described in INSTALL). 93*0Sstevel@tonic-gateIn addition, you can read the most current versions at 94*0Sstevel@tonic-gate<URL: http://www.openssl.org/docs/>. 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gateFor information on parts of libcrypto that are not yet documented, you 97*0Sstevel@tonic-gatemight want to read Ariel Glenn's documentation on SSLeay 0.9, OpenSSL's 98*0Sstevel@tonic-gatepredecessor, at <URL: http://www.columbia.edu/~ariel/ssleay/>. Much 99*0Sstevel@tonic-gateof this still applies to OpenSSL. 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gateThere is some documentation about certificate extensions and PKCS#12 102*0Sstevel@tonic-gatein doc/openssl.txt 103*0Sstevel@tonic-gate 104*0Sstevel@tonic-gateThe original SSLeay documentation is included in OpenSSL as 105*0Sstevel@tonic-gatedoc/ssleay.txt. It may be useful when none of the other resources 106*0Sstevel@tonic-gatehelp, but please note that it reflects the obsolete version SSLeay 107*0Sstevel@tonic-gate0.6.6. 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate* How can I contact the OpenSSL developers? 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gateThe README file describes how to submit bug reports and patches to 113*0Sstevel@tonic-gateOpenSSL. Information on the OpenSSL mailing lists is available from 114*0Sstevel@tonic-gate<URL: http://www.openssl.org>. 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate* Where can I get a compiled version of OpenSSL? 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gateYou can finder pointers to binary distributions in 120*0Sstevel@tonic-gatehttp://www.openssl.org/related/binaries.html . 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gateSome applications that use OpenSSL are distributed in binary form. 123*0Sstevel@tonic-gateWhen using such an application, you don't need to install OpenSSL 124*0Sstevel@tonic-gateyourself; the application will include the required parts (e.g. DLLs). 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gateIf you want to build OpenSSL on a Windows system and you don't have 127*0Sstevel@tonic-gatea C compiler, read the "Mingw32" section of INSTALL.W32 for information 128*0Sstevel@tonic-gateon how to obtain and install the free GNU C compiler. 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gateA number of Linux and *BSD distributions include OpenSSL. 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate* Why aren't tools like 'autoconf' and 'libtool' used? 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gateautoconf will probably be used in future OpenSSL versions. If it was 136*0Sstevel@tonic-gateless Unix-centric, it might have been used much earlier. 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate* What is an 'engine' version? 139*0Sstevel@tonic-gate 140*0Sstevel@tonic-gateWith version 0.9.6 OpenSSL was extended to interface to external crypto 141*0Sstevel@tonic-gatehardware. This was realized in a special release '0.9.6-engine'. With 142*0Sstevel@tonic-gateversion 0.9.7 (not yet released) the changes were merged into the main 143*0Sstevel@tonic-gatedevelopment line, so that the special release is no longer necessary. 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate* How do I check the authenticity of the OpenSSL distribution? 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gateWe provide MD5 digests and ASC signatures of each tarball. 148*0Sstevel@tonic-gateUse MD5 to check that a tarball from a mirror site is identical: 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate md5sum TARBALL | awk '{print $1;}' | cmp - TARBALL.md5 151*0Sstevel@tonic-gate 152*0Sstevel@tonic-gateYou can check authenticity using pgp or gpg. You need the OpenSSL team 153*0Sstevel@tonic-gatemember public key used to sign it (download it from a key server). Then 154*0Sstevel@tonic-gatejust do: 155*0Sstevel@tonic-gate 156*0Sstevel@tonic-gate pgp TARBALL.asc 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate[LEGAL] ======================================================================= 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate* Do I need patent licenses to use OpenSSL? 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gateThe patents section of the README file lists patents that may apply to 163*0Sstevel@tonic-gateyou if you want to use OpenSSL. For information on intellectual 164*0Sstevel@tonic-gateproperty rights, please consult a lawyer. The OpenSSL team does not 165*0Sstevel@tonic-gateoffer legal advice. 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gateYou can configure OpenSSL so as not to use RC5 and IDEA by using 168*0Sstevel@tonic-gate ./config no-rc5 no-idea 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate* Can I use OpenSSL with GPL software? 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gateOn many systems including the major Linux and BSD distributions, yes (the 174*0Sstevel@tonic-gateGPL does not place restrictions on using libraries that are part of the 175*0Sstevel@tonic-gatenormal operating system distribution). 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gateOn other systems, the situation is less clear. Some GPL software copyright 178*0Sstevel@tonic-gateholders claim that you infringe on their rights if you use OpenSSL with 179*0Sstevel@tonic-gatetheir software on operating systems that don't normally include OpenSSL. 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gateIf you develop open source software that uses OpenSSL, you may find it 182*0Sstevel@tonic-gateuseful to choose an other license than the GPL, or state explicitly that 183*0Sstevel@tonic-gate"This program is released under the GPL with the additional exemption that 184*0Sstevel@tonic-gatecompiling, linking, and/or using OpenSSL is allowed." If you are using 185*0Sstevel@tonic-gateGPL software developed by others, you may want to ask the copyright holder 186*0Sstevel@tonic-gatefor permission to use their software with OpenSSL. 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate 189*0Sstevel@tonic-gate[USER] ======================================================================== 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate* Why do I get a "PRNG not seeded" error message? 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gateCryptographic software needs a source of unpredictable data to work 194*0Sstevel@tonic-gatecorrectly. Many open source operating systems provide a "randomness 195*0Sstevel@tonic-gatedevice" (/dev/urandom or /dev/random) that serves this purpose. 196*0Sstevel@tonic-gateAll OpenSSL versions try to use /dev/urandom by default; starting with 197*0Sstevel@tonic-gateversion 0.9.7, OpenSSL also tries /dev/random if /dev/urandom is not 198*0Sstevel@tonic-gateavailable. 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gateOn other systems, applications have to call the RAND_add() or 201*0Sstevel@tonic-gateRAND_seed() function with appropriate data before generating keys or 202*0Sstevel@tonic-gateperforming public key encryption. (These functions initialize the 203*0Sstevel@tonic-gatepseudo-random number generator, PRNG.) Some broken applications do 204*0Sstevel@tonic-gatenot do this. As of version 0.9.5, the OpenSSL functions that need 205*0Sstevel@tonic-gaterandomness report an error if the random number generator has not been 206*0Sstevel@tonic-gateseeded with at least 128 bits of randomness. If this error occurs and 207*0Sstevel@tonic-gateis not discussed in the documentation of the application you are 208*0Sstevel@tonic-gateusing, please contact the author of that application; it is likely 209*0Sstevel@tonic-gatethat it never worked correctly. OpenSSL 0.9.5 and later make the 210*0Sstevel@tonic-gateerror visible by refusing to perform potentially insecure encryption. 211*0Sstevel@tonic-gate 212*0Sstevel@tonic-gateIf you are using Solaris 8, you can add /dev/urandom and /dev/random 213*0Sstevel@tonic-gatedevices by installing patch 112438 (Sparc) or 112439 (x86), which are 214*0Sstevel@tonic-gateavailable via the Patchfinder at <URL: http://sunsolve.sun.com> 215*0Sstevel@tonic-gate(Solaris 9 includes these devices by default). For /dev/random support 216*0Sstevel@tonic-gatefor earlier Solaris versions, see Sun's statement at 217*0Sstevel@tonic-gate<URL: http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb/27606&zone_32=SUNWski> 218*0Sstevel@tonic-gate(the SUNWski package is available in patch 105710). 219*0Sstevel@tonic-gate 220*0Sstevel@tonic-gateOn systems without /dev/urandom and /dev/random, it is a good idea to 221*0Sstevel@tonic-gateuse the Entropy Gathering Demon (EGD); see the RAND_egd() manpage for 222*0Sstevel@tonic-gatedetails. Starting with version 0.9.7, OpenSSL will automatically look 223*0Sstevel@tonic-gatefor an EGD socket at /var/run/egd-pool, /dev/egd-pool, /etc/egd-pool and 224*0Sstevel@tonic-gate/etc/entropy. 225*0Sstevel@tonic-gate 226*0Sstevel@tonic-gateMost components of the openssl command line utility automatically try 227*0Sstevel@tonic-gateto seed the random number generator from a file. The name of the 228*0Sstevel@tonic-gatedefault seeding file is determined as follows: If environment variable 229*0Sstevel@tonic-gateRANDFILE is set, then it names the seeding file. Otherwise if 230*0Sstevel@tonic-gateenvironment variable HOME is set, then the seeding file is $HOME/.rnd. 231*0Sstevel@tonic-gateIf neither RANDFILE nor HOME is set, versions up to OpenSSL 0.9.6 will 232*0Sstevel@tonic-gateuse file .rnd in the current directory while OpenSSL 0.9.6a uses no 233*0Sstevel@tonic-gatedefault seeding file at all. OpenSSL 0.9.6b and later will behave 234*0Sstevel@tonic-gatesimilarly to 0.9.6a, but will use a default of "C:\" for HOME on 235*0Sstevel@tonic-gateWindows systems if the environment variable has not been set. 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gateIf the default seeding file does not exist or is too short, the "PRNG 238*0Sstevel@tonic-gatenot seeded" error message may occur. 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gateThe openssl command line utility will write back a new state to the 241*0Sstevel@tonic-gatedefault seeding file (and create this file if necessary) unless 242*0Sstevel@tonic-gatethere was no sufficient seeding. 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gatePointing $RANDFILE to an Entropy Gathering Daemon socket does not work. 245*0Sstevel@tonic-gateUse the "-rand" option of the OpenSSL command line tools instead. 246*0Sstevel@tonic-gateThe $RANDFILE environment variable and $HOME/.rnd are only used by the 247*0Sstevel@tonic-gateOpenSSL command line tools. Applications using the OpenSSL library 248*0Sstevel@tonic-gateprovide their own configuration options to specify the entropy source, 249*0Sstevel@tonic-gateplease check out the documentation coming the with application. 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate* Why do I get an "unable to write 'random state'" error message? 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gateSometimes the openssl command line utility does not abort with 256*0Sstevel@tonic-gatea "PRNG not seeded" error message, but complains that it is 257*0Sstevel@tonic-gate"unable to write 'random state'". This message refers to the 258*0Sstevel@tonic-gatedefault seeding file (see previous answer). A possible reason 259*0Sstevel@tonic-gateis that no default filename is known because neither RANDFILE 260*0Sstevel@tonic-gatenor HOME is set. (Versions up to 0.9.6 used file ".rnd" in the 261*0Sstevel@tonic-gatecurrent directory in this case, but this has changed with 0.9.6a.) 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate* How do I create certificates or certificate requests? 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gateCheck out the CA.pl(1) manual page. This provides a simple wrapper round 267*0Sstevel@tonic-gatethe 'req', 'verify', 'ca' and 'pkcs12' utilities. For finer control check 268*0Sstevel@tonic-gateout the manual pages for the individual utilities and the certificate 269*0Sstevel@tonic-gateextensions documentation (currently in doc/openssl.txt). 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gate 272*0Sstevel@tonic-gate* Why can't I create certificate requests? 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gateYou typically get the error: 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gate unable to find 'distinguished_name' in config 277*0Sstevel@tonic-gate problems making Certificate Request 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gateThis is because it can't find the configuration file. Check out the 280*0Sstevel@tonic-gateDIAGNOSTICS section of req(1) for more information. 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate* Why does <SSL program> fail with a certificate verify error? 284*0Sstevel@tonic-gate 285*0Sstevel@tonic-gateThis problem is usually indicated by log messages saying something like 286*0Sstevel@tonic-gate"unable to get local issuer certificate" or "self signed certificate". 287*0Sstevel@tonic-gateWhen a certificate is verified its root CA must be "trusted" by OpenSSL 288*0Sstevel@tonic-gatethis typically means that the CA certificate must be placed in a directory 289*0Sstevel@tonic-gateor file and the relevant program configured to read it. The OpenSSL program 290*0Sstevel@tonic-gate'verify' behaves in a similar way and issues similar error messages: check 291*0Sstevel@tonic-gatethe verify(1) program manual page for more information. 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate* Why can I only use weak ciphers when I connect to a server using OpenSSL? 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gateThis is almost certainly because you are using an old "export grade" browser 297*0Sstevel@tonic-gatewhich only supports weak encryption. Upgrade your browser to support 128 bit 298*0Sstevel@tonic-gateciphers. 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate* How can I create DSA certificates? 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gateCheck the CA.pl(1) manual page for a DSA certificate example. 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate* Why can't I make an SSL connection to a server using a DSA certificate? 307*0Sstevel@tonic-gate 308*0Sstevel@tonic-gateTypically you'll see a message saying there are no shared ciphers when 309*0Sstevel@tonic-gatethe same setup works fine with an RSA certificate. There are two possible 310*0Sstevel@tonic-gatecauses. The client may not support connections to DSA servers most web 311*0Sstevel@tonic-gatebrowsers (including Netscape and MSIE) only support connections to servers 312*0Sstevel@tonic-gatesupporting RSA cipher suites. The other cause is that a set of DH parameters 313*0Sstevel@tonic-gatehas not been supplied to the server. DH parameters can be created with the 314*0Sstevel@tonic-gatedhparam(1) command and loaded using the SSL_CTX_set_tmp_dh() for example: 315*0Sstevel@tonic-gatecheck the source to s_server in apps/s_server.c for an example. 316*0Sstevel@tonic-gate 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate* How can I remove the passphrase on a private key? 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gateFirstly you should be really *really* sure you want to do this. Leaving 321*0Sstevel@tonic-gatea private key unencrypted is a major security risk. If you decide that 322*0Sstevel@tonic-gateyou do have to do this check the EXAMPLES sections of the rsa(1) and 323*0Sstevel@tonic-gatedsa(1) manual pages. 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate 326*0Sstevel@tonic-gate* Why can't I use OpenSSL certificates with SSL client authentication? 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gateWhat will typically happen is that when a server requests authentication 329*0Sstevel@tonic-gateit will either not include your certificate or tell you that you have 330*0Sstevel@tonic-gateno client certificates (Netscape) or present you with an empty list box 331*0Sstevel@tonic-gate(MSIE). The reason for this is that when a server requests a client 332*0Sstevel@tonic-gatecertificate it includes a list of CAs names which it will accept. Browsers 333*0Sstevel@tonic-gatewill only let you select certificates from the list on the grounds that 334*0Sstevel@tonic-gatethere is little point presenting a certificate which the server will 335*0Sstevel@tonic-gatereject. 336*0Sstevel@tonic-gate 337*0Sstevel@tonic-gateThe solution is to add the relevant CA certificate to your servers "trusted 338*0Sstevel@tonic-gateCA list". How you do this depends on the server software in uses. You can 339*0Sstevel@tonic-gateprint out the servers list of acceptable CAs using the OpenSSL s_client tool: 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gateopenssl s_client -connect www.some.host:443 -prexit 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gateIf your server only requests certificates on certain URLs then you may need 344*0Sstevel@tonic-gateto manually issue an HTTP GET command to get the list when s_client connects: 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gateGET /some/page/needing/a/certificate.html 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gateIf your CA does not appear in the list then this confirms the problem. 349*0Sstevel@tonic-gate 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate* Why does my browser give a warning about a mismatched hostname? 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gateBrowsers expect the server's hostname to match the value in the commonName 354*0Sstevel@tonic-gate(CN) field of the certificate. If it does not then you get a warning. 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate 357*0Sstevel@tonic-gate* How do I install a CA certificate into a browser? 358*0Sstevel@tonic-gate 359*0Sstevel@tonic-gateThe usual way is to send the DER encoded certificate to the browser as 360*0Sstevel@tonic-gateMIME type application/x-x509-ca-cert, for example by clicking on an appropriate 361*0Sstevel@tonic-gatelink. On MSIE certain extensions such as .der or .cacert may also work, or you 362*0Sstevel@tonic-gatecan import the certificate using the certificate import wizard. 363*0Sstevel@tonic-gate 364*0Sstevel@tonic-gateYou can convert a certificate to DER form using the command: 365*0Sstevel@tonic-gate 366*0Sstevel@tonic-gateopenssl x509 -in ca.pem -outform DER -out ca.der 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gateOccasionally someone suggests using a command such as: 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gateopenssl pkcs12 -export -out cacert.p12 -in cacert.pem -inkey cakey.pem 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gateDO NOT DO THIS! This command will give away your CAs private key and 373*0Sstevel@tonic-gatereduces its security to zero: allowing anyone to forge certificates in 374*0Sstevel@tonic-gatewhatever name they choose. 375*0Sstevel@tonic-gate 376*0Sstevel@tonic-gate* Why is OpenSSL x509 DN output not conformant to RFC2253? 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gateThe ways to print out the oneline format of the DN (Distinguished Name) have 379*0Sstevel@tonic-gatebeen extended in version 0.9.7 of OpenSSL. Using the new X509_NAME_print_ex() 380*0Sstevel@tonic-gateinterface, the "-nameopt" option could be introduded. See the manual 381*0Sstevel@tonic-gatepage of the "openssl x509" commandline tool for details. The old behaviour 382*0Sstevel@tonic-gatehas however been left as default for the sake of compatibility. 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate[BUILD] ======================================================================= 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gate* Why does the linker complain about undefined symbols? 387*0Sstevel@tonic-gate 388*0Sstevel@tonic-gateMaybe the compilation was interrupted, and make doesn't notice that 389*0Sstevel@tonic-gatesomething is missing. Run "make clean; make". 390*0Sstevel@tonic-gate 391*0Sstevel@tonic-gateIf you used ./Configure instead of ./config, make sure that you 392*0Sstevel@tonic-gateselected the right target. File formats may differ slightly between 393*0Sstevel@tonic-gateOS versions (for example sparcv8/sparcv9, or a.out/elf). 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gateIn case you get errors about the following symbols, use the config 396*0Sstevel@tonic-gateoption "no-asm", as described in INSTALL: 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate BF_cbc_encrypt, BF_decrypt, BF_encrypt, CAST_cbc_encrypt, 399*0Sstevel@tonic-gate CAST_decrypt, CAST_encrypt, RC4, RC5_32_cbc_encrypt, RC5_32_decrypt, 400*0Sstevel@tonic-gate RC5_32_encrypt, bn_add_words, bn_div_words, bn_mul_add_words, 401*0Sstevel@tonic-gate bn_mul_comba4, bn_mul_comba8, bn_mul_words, bn_sqr_comba4, 402*0Sstevel@tonic-gate bn_sqr_comba8, bn_sqr_words, bn_sub_words, des_decrypt3, 403*0Sstevel@tonic-gate des_ede3_cbc_encrypt, des_encrypt, des_encrypt2, des_encrypt3, 404*0Sstevel@tonic-gate des_ncbc_encrypt, md5_block_asm_host_order, sha1_block_asm_data_order 405*0Sstevel@tonic-gate 406*0Sstevel@tonic-gateIf none of these helps, you may want to try using the current snapshot. 407*0Sstevel@tonic-gateIf the problem persists, please submit a bug report. 408*0Sstevel@tonic-gate 409*0Sstevel@tonic-gate 410*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: command not found"? 411*0Sstevel@tonic-gate 412*0Sstevel@tonic-gateYou didn't install "bc", the Unix calculator. If you want to run the 413*0Sstevel@tonic-gatetests, get GNU bc from ftp://ftp.gnu.org or from your OS distributor. 414*0Sstevel@tonic-gate 415*0Sstevel@tonic-gate 416*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: 1 no implemented"? 417*0Sstevel@tonic-gate 418*0Sstevel@tonic-gateOn some SCO installations or versions, bc has a bug that gets triggered 419*0Sstevel@tonic-gatewhen you run the test suite (using "make test"). The message returned is 420*0Sstevel@tonic-gate"bc: 1 not implemented". 421*0Sstevel@tonic-gate 422*0Sstevel@tonic-gateThe best way to deal with this is to find another implementation of bc 423*0Sstevel@tonic-gateand compile/install it. GNU bc (see http://www.gnu.org/software/software.html 424*0Sstevel@tonic-gatefor download instructions) can be safely used, for example. 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate* Why does the OpenSSL test fail with "bc: stack empty"? 428*0Sstevel@tonic-gate 429*0Sstevel@tonic-gateOn some DG/ux versions, bc seems to have a too small stack for calculations 430*0Sstevel@tonic-gatethat the OpenSSL bntest throws at it. This gets triggered when you run the 431*0Sstevel@tonic-gatetest suite (using "make test"). The message returned is "bc: stack empty". 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gateThe best way to deal with this is to find another implementation of bc 434*0Sstevel@tonic-gateand compile/install it. GNU bc (see http://www.gnu.org/software/software.html 435*0Sstevel@tonic-gatefor download instructions) can be safely used, for example. 436*0Sstevel@tonic-gate 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Alpha Tru64 Unix? 439*0Sstevel@tonic-gate 440*0Sstevel@tonic-gateOn some Alpha installations running Tru64 Unix and Compaq C, the compilation 441*0Sstevel@tonic-gateof crypto/sha/sha_dgst.c fails with the message 'Fatal: Insufficient virtual 442*0Sstevel@tonic-gatememory to continue compilation.' As far as the tests have shown, this may be 443*0Sstevel@tonic-gatea compiler bug. What happens is that it eats up a lot of resident memory 444*0Sstevel@tonic-gateto build something, probably a table. The problem is clearly in the 445*0Sstevel@tonic-gateoptimization code, because if one eliminates optimization completely (-O0), 446*0Sstevel@tonic-gatethe compilation goes through (and the compiler consumes about 2MB of resident 447*0Sstevel@tonic-gatememory instead of 240MB or whatever one's limit is currently). 448*0Sstevel@tonic-gate 449*0Sstevel@tonic-gateThere are three options to solve this problem: 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate1. set your current data segment size soft limit higher. Experience shows 452*0Sstevel@tonic-gatethat about 241000 kbytes seems to be enough on an AlphaServer DS10. You do 453*0Sstevel@tonic-gatethis with the command 'ulimit -Sd nnnnnn', where 'nnnnnn' is the number of 454*0Sstevel@tonic-gatekbytes to set the limit to. 455*0Sstevel@tonic-gate 456*0Sstevel@tonic-gate2. If you have a hard limit that is lower than what you need and you can't 457*0Sstevel@tonic-gateget it changed, you can compile all of OpenSSL with -O0 as optimization 458*0Sstevel@tonic-gatelevel. This is however not a very nice thing to do for those who expect to 459*0Sstevel@tonic-gateget the best result from OpenSSL. A bit more complicated solution is the 460*0Sstevel@tonic-gatefollowing: 461*0Sstevel@tonic-gate 462*0Sstevel@tonic-gate----- snip:start ----- 463*0Sstevel@tonic-gate make DIRS=crypto SDIRS=sha "`grep '^CFLAG=' Makefile.ssl | \ 464*0Sstevel@tonic-gate sed -e 's/ -O[0-9] / -O0 /'`" 465*0Sstevel@tonic-gate rm `ls crypto/*.o crypto/sha/*.o | grep -v 'sha_dgst\.o'` 466*0Sstevel@tonic-gate make 467*0Sstevel@tonic-gate----- snip:end ----- 468*0Sstevel@tonic-gate 469*0Sstevel@tonic-gateThis will only compile sha_dgst.c with -O0, the rest with the optimization 470*0Sstevel@tonic-gatelevel chosen by the configuration process. When the above is done, do the 471*0Sstevel@tonic-gatetest and installation and you're set. 472*0Sstevel@tonic-gate 473*0Sstevel@tonic-gate 474*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail with "ar: command not found"? 475*0Sstevel@tonic-gate 476*0Sstevel@tonic-gateGetting this message is quite usual on Solaris 2, because Sun has hidden 477*0Sstevel@tonic-gateaway 'ar' and other development commands in directories that aren't in 478*0Sstevel@tonic-gate$PATH by default. One of those directories is '/usr/ccs/bin'. The 479*0Sstevel@tonic-gatequickest way to fix this is to do the following (it assumes you use sh 480*0Sstevel@tonic-gateor any sh-compatible shell): 481*0Sstevel@tonic-gate 482*0Sstevel@tonic-gate----- snip:start ----- 483*0Sstevel@tonic-gate PATH=${PATH}:/usr/ccs/bin; export PATH 484*0Sstevel@tonic-gate----- snip:end ----- 485*0Sstevel@tonic-gate 486*0Sstevel@tonic-gateand then redo the compilation. What you should really do is make sure 487*0Sstevel@tonic-gate'/usr/ccs/bin' is permanently in your $PATH, for example through your 488*0Sstevel@tonic-gate'.profile' (again, assuming you use a sh-compatible shell). 489*0Sstevel@tonic-gate 490*0Sstevel@tonic-gate 491*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on Win32 with VC++? 492*0Sstevel@tonic-gate 493*0Sstevel@tonic-gateSometimes, you may get reports from VC++ command line (cl) that it 494*0Sstevel@tonic-gatecan't find standard include files like stdio.h and other weirdnesses. 495*0Sstevel@tonic-gateOne possible cause is that the environment isn't correctly set up. 496*0Sstevel@tonic-gateTo solve that problem for VC++ versions up to 6, one should run 497*0Sstevel@tonic-gateVCVARS32.BAT which is found in the 'bin' subdirectory of the VC++ 498*0Sstevel@tonic-gateinstallation directory (somewhere under 'Program Files'). For VC++ 499*0Sstevel@tonic-gateversion 7 (and up?), which is also called VS.NET, the file is called 500*0Sstevel@tonic-gateVSVARS32.BAT instead. 501*0Sstevel@tonic-gateThis needs to be done prior to running NMAKE, and the changes are only 502*0Sstevel@tonic-gatevalid for the current DOS session. 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate 505*0Sstevel@tonic-gate* What is special about OpenSSL on Redhat? 506*0Sstevel@tonic-gate 507*0Sstevel@tonic-gateRed Hat Linux (release 7.0 and later) include a preinstalled limited 508*0Sstevel@tonic-gateversion of OpenSSL. For patent reasons, support for IDEA, RC5 and MDC2 509*0Sstevel@tonic-gateis disabled in this version. The same may apply to other Linux distributions. 510*0Sstevel@tonic-gateUsers may therefore wish to install more or all of the features left out. 511*0Sstevel@tonic-gate 512*0Sstevel@tonic-gateTo do this you MUST ensure that you do not overwrite the openssl that is in 513*0Sstevel@tonic-gate/usr/bin on your Red Hat machine. Several packages depend on this file, 514*0Sstevel@tonic-gateincluding sendmail and ssh. /usr/local/bin is a good alternative choice. The 515*0Sstevel@tonic-gatelibraries that come with Red Hat 7.0 onwards have different names and so are 516*0Sstevel@tonic-gatenot affected. (eg For Red Hat 7.2 they are /lib/libssl.so.0.9.6b and 517*0Sstevel@tonic-gate/lib/libcrypto.so.0.9.6b with symlinks /lib/libssl.so.2 and 518*0Sstevel@tonic-gate/lib/libcrypto.so.2 respectively). 519*0Sstevel@tonic-gate 520*0Sstevel@tonic-gatePlease note that we have been advised by Red Hat attempting to recompile the 521*0Sstevel@tonic-gateopenssl rpm with all the cryptography enabled will not work. All other 522*0Sstevel@tonic-gatepackages depend on the original Red Hat supplied openssl package. It is also 523*0Sstevel@tonic-gateworth noting that due to the way Red Hat supplies its packages, updates to 524*0Sstevel@tonic-gateopenssl on each distribution never change the package version, only the 525*0Sstevel@tonic-gatebuild number. For example, on Red Hat 7.1, the latest openssl package has 526*0Sstevel@tonic-gateversion number 0.9.6 and build number 9 even though it contains all the 527*0Sstevel@tonic-gaterelevant updates in packages up to and including 0.9.6b. 528*0Sstevel@tonic-gate 529*0Sstevel@tonic-gateA possible way around this is to persuade Red Hat to produce a non-US 530*0Sstevel@tonic-gateversion of Red Hat Linux. 531*0Sstevel@tonic-gate 532*0Sstevel@tonic-gateFYI: Patent numbers and expiry dates of US patents: 533*0Sstevel@tonic-gateMDC-2: 4,908,861 13/03/2007 534*0Sstevel@tonic-gateIDEA: 5,214,703 25/05/2010 535*0Sstevel@tonic-gateRC5: 5,724,428 03/03/2015 536*0Sstevel@tonic-gate 537*0Sstevel@tonic-gate 538*0Sstevel@tonic-gate* Why does the OpenSSL compilation fail on MacOS X? 539*0Sstevel@tonic-gate 540*0Sstevel@tonic-gateIf the failure happens when trying to build the "openssl" binary, with 541*0Sstevel@tonic-gatea large number of undefined symbols, it's very probable that you have 542*0Sstevel@tonic-gateOpenSSL 0.9.6b delivered with the operating system (you can find out by 543*0Sstevel@tonic-gaterunning '/usr/bin/openssl version') and that you were trying to build 544*0Sstevel@tonic-gateOpenSSL 0.9.7 or newer. The problem is that the loader ('ld') in 545*0Sstevel@tonic-gateMacOS X has a misfeature that's quite difficult to go around. 546*0Sstevel@tonic-gateLook in the file PROBLEMS for a more detailed explanation and for possible 547*0Sstevel@tonic-gatesolutions. 548*0Sstevel@tonic-gate 549*0Sstevel@tonic-gate 550*0Sstevel@tonic-gate* Why does the OpenSSL test suite fail on MacOS X? 551*0Sstevel@tonic-gate 552*0Sstevel@tonic-gateIf the failure happens when running 'make test' and the RC4 test fails, 553*0Sstevel@tonic-gateit's very probable that you have OpenSSL 0.9.6b delivered with the 554*0Sstevel@tonic-gateoperating system (you can find out by running '/usr/bin/openssl version') 555*0Sstevel@tonic-gateand that you were trying to build OpenSSL 0.9.6d. The problem is that 556*0Sstevel@tonic-gatethe loader ('ld') in MacOS X has a misfeature that's quite difficult to 557*0Sstevel@tonic-gatego around and has linked the programs "openssl" and the test programs 558*0Sstevel@tonic-gatewith /usr/lib/libcrypto.dylib and /usr/lib/libssl.dylib instead of the 559*0Sstevel@tonic-gatelibraries you just built. 560*0Sstevel@tonic-gateLook in the file PROBLEMS for a more detailed explanation and for possible 561*0Sstevel@tonic-gatesolutions. 562*0Sstevel@tonic-gate 563*0Sstevel@tonic-gate* Why does the OpenSSL test suite fail in BN_sqr test [on a 64-bit platform]? 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gateFailure in BN_sqr test is most likely caused by a failure to configure the 566*0Sstevel@tonic-gatetoolkit for current platform or lack of support for the platform in question. 567*0Sstevel@tonic-gateRun './config -t' and './apps/openssl version -p'. Do these platform 568*0Sstevel@tonic-gateidentifiers match? If they don't, then you most likely failed to run 569*0Sstevel@tonic-gate./config and you're hereby advised to do so before filing a bug report. 570*0Sstevel@tonic-gateIf ./config itself fails to run, then it's most likely problem with your 571*0Sstevel@tonic-gatelocal environment and you should turn to your system administrator (or 572*0Sstevel@tonic-gatesimilar). If identifiers match (and/or no alternative identifier is 573*0Sstevel@tonic-gatesuggested by ./config script), then the platform is unsupported. There might 574*0Sstevel@tonic-gateor might not be a workaround. Most notably on SPARC64 platforms with GNU 575*0Sstevel@tonic-gateC compiler you should be able to produce a working build by running 576*0Sstevel@tonic-gate'./config -m32'. I understand that -m32 might not be what you want/need, 577*0Sstevel@tonic-gatebut the build should be operational. For further details turn to 578*0Sstevel@tonic-gate<openssl-dev@openssl.org>. 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gate* Why does OpenBSD-i386 build fail on des-586.s with "Unimplemented segment type"? 581*0Sstevel@tonic-gate 582*0Sstevel@tonic-gateAs of 0.9.7 assembler routines were overhauled for position independence 583*0Sstevel@tonic-gateof the machine code, which is essential for shared library support. For 584*0Sstevel@tonic-gatesome reason OpenBSD is equipped with an out-of-date GNU assembler which 585*0Sstevel@tonic-gatefinds the new code offensive. To work around the problem, configure with 586*0Sstevel@tonic-gateno-asm (and sacrifice a great deal of performance) or patch your assembler 587*0Sstevel@tonic-gateaccording to <URL: http://www.openssl.org/~appro/gas-1.92.3.OpenBSD.patch>. 588*0Sstevel@tonic-gateFor your convenience a pre-compiled replacement binary is provided at 589*0Sstevel@tonic-gate<URL: http://www.openssl.org/~appro/gas-1.92.3.static.aout.bin>. 590*0Sstevel@tonic-gateReportedly elder *BSD a.out platforms also suffer from this problem and 591*0Sstevel@tonic-gateremedy should be same. Provided binary is statically linked and should be 592*0Sstevel@tonic-gateworking across wider range of *BSD branches, not just OpenBSD. 593*0Sstevel@tonic-gate 594*0Sstevel@tonic-gate[PROG] ======================================================================== 595*0Sstevel@tonic-gate 596*0Sstevel@tonic-gate* Is OpenSSL thread-safe? 597*0Sstevel@tonic-gate 598*0Sstevel@tonic-gateYes (with limitations: an SSL connection may not concurrently be used 599*0Sstevel@tonic-gateby multiple threads). On Windows and many Unix systems, OpenSSL 600*0Sstevel@tonic-gateautomatically uses the multi-threaded versions of the standard 601*0Sstevel@tonic-gatelibraries. If your platform is not one of these, consult the INSTALL 602*0Sstevel@tonic-gatefile. 603*0Sstevel@tonic-gate 604*0Sstevel@tonic-gateMulti-threaded applications must provide two callback functions to 605*0Sstevel@tonic-gateOpenSSL. This is described in the threads(3) manpage. 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate 608*0Sstevel@tonic-gate* I've compiled a program under Windows and it crashes: why? 609*0Sstevel@tonic-gate 610*0Sstevel@tonic-gateThis is usually because you've missed the comment in INSTALL.W32. 611*0Sstevel@tonic-gateYour application must link against the same version of the Win32 612*0Sstevel@tonic-gateC-Runtime against which your openssl libraries were linked. The 613*0Sstevel@tonic-gatedefault version for OpenSSL is /MD - "Multithreaded DLL". 614*0Sstevel@tonic-gate 615*0Sstevel@tonic-gateIf you are using Microsoft Visual C++'s IDE (Visual Studio), in 616*0Sstevel@tonic-gatemany cases, your new project most likely defaulted to "Debug 617*0Sstevel@tonic-gateSinglethreaded" - /ML. This is NOT interchangeable with /MD and your 618*0Sstevel@tonic-gateprogram will crash, typically on the first BIO related read or write 619*0Sstevel@tonic-gateoperation. 620*0Sstevel@tonic-gate 621*0Sstevel@tonic-gateFor each of the six possible link stage configurations within Win32, 622*0Sstevel@tonic-gateyour application must link against the same by which OpenSSL was 623*0Sstevel@tonic-gatebuilt. If you are using MS Visual C++ (Studio) this can be changed 624*0Sstevel@tonic-gateby: 625*0Sstevel@tonic-gate 626*0Sstevel@tonic-gate1. Select Settings... from the Project Menu. 627*0Sstevel@tonic-gate2. Select the C/C++ Tab. 628*0Sstevel@tonic-gate3. Select "Code Generation from the "Category" drop down list box 629*0Sstevel@tonic-gate4. Select the Appropriate library (see table below) from the "Use 630*0Sstevel@tonic-gate run-time library" drop down list box. Perform this step for both 631*0Sstevel@tonic-gate your debug and release versions of your application (look at the 632*0Sstevel@tonic-gate top left of the settings panel to change between the two) 633*0Sstevel@tonic-gate 634*0Sstevel@tonic-gate Single Threaded /ML - MS VC++ often defaults to 635*0Sstevel@tonic-gate this for the release 636*0Sstevel@tonic-gate version of a new project. 637*0Sstevel@tonic-gate Debug Single Threaded /MLd - MS VC++ often defaults to 638*0Sstevel@tonic-gate this for the debug version 639*0Sstevel@tonic-gate of a new project. 640*0Sstevel@tonic-gate Multithreaded /MT 641*0Sstevel@tonic-gate Debug Multithreaded /MTd 642*0Sstevel@tonic-gate Multithreaded DLL /MD - OpenSSL defaults to this. 643*0Sstevel@tonic-gate Debug Multithreaded DLL /MDd 644*0Sstevel@tonic-gate 645*0Sstevel@tonic-gateNote that debug and release libraries are NOT interchangeable. If you 646*0Sstevel@tonic-gatebuilt OpenSSL with /MD your application must use /MD and cannot use /MDd. 647*0Sstevel@tonic-gate 648*0Sstevel@tonic-gate 649*0Sstevel@tonic-gate* How do I read or write a DER encoded buffer using the ASN1 functions? 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gateYou have two options. You can either use a memory BIO in conjunction 652*0Sstevel@tonic-gatewith the i2d_XXX_bio() or d2i_XXX_bio() functions or you can use the 653*0Sstevel@tonic-gatei2d_XXX(), d2i_XXX() functions directly. Since these are often the 654*0Sstevel@tonic-gatecause of grief here are some code fragments using PKCS7 as an example: 655*0Sstevel@tonic-gate 656*0Sstevel@tonic-gateunsigned char *buf, *p; 657*0Sstevel@tonic-gateint len; 658*0Sstevel@tonic-gate 659*0Sstevel@tonic-gatelen = i2d_PKCS7(p7, NULL); 660*0Sstevel@tonic-gatebuf = OPENSSL_malloc(len); /* or Malloc, error checking omitted */ 661*0Sstevel@tonic-gatep = buf; 662*0Sstevel@tonic-gatei2d_PKCS7(p7, &p); 663*0Sstevel@tonic-gate 664*0Sstevel@tonic-gateAt this point buf contains the len bytes of the DER encoding of 665*0Sstevel@tonic-gatep7. 666*0Sstevel@tonic-gate 667*0Sstevel@tonic-gateThe opposite assumes we already have len bytes in buf: 668*0Sstevel@tonic-gate 669*0Sstevel@tonic-gateunsigned char *p; 670*0Sstevel@tonic-gatep = buf; 671*0Sstevel@tonic-gatep7 = d2i_PKCS7(NULL, &p, len); 672*0Sstevel@tonic-gate 673*0Sstevel@tonic-gateAt this point p7 contains a valid PKCS7 structure of NULL if an error 674*0Sstevel@tonic-gateoccurred. If an error occurred ERR_print_errors(bio) should give more 675*0Sstevel@tonic-gateinformation. 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gateThe reason for the temporary variable 'p' is that the ASN1 functions 678*0Sstevel@tonic-gateincrement the passed pointer so it is ready to read or write the next 679*0Sstevel@tonic-gatestructure. This is often a cause of problems: without the temporary 680*0Sstevel@tonic-gatevariable the buffer pointer is changed to point just after the data 681*0Sstevel@tonic-gatethat has been read or written. This may well be uninitialized data 682*0Sstevel@tonic-gateand attempts to free the buffer will have unpredictable results 683*0Sstevel@tonic-gatebecause it no longer points to the same address. 684*0Sstevel@tonic-gate 685*0Sstevel@tonic-gate 686*0Sstevel@tonic-gate* I've tried using <M_some_evil_pkcs12_macro> and I get errors why? 687*0Sstevel@tonic-gate 688*0Sstevel@tonic-gateThis usually happens when you try compiling something using the PKCS#12 689*0Sstevel@tonic-gatemacros with a C++ compiler. There is hardly ever any need to use the 690*0Sstevel@tonic-gatePKCS#12 macros in a program, it is much easier to parse and create 691*0Sstevel@tonic-gatePKCS#12 files using the PKCS12_parse() and PKCS12_create() functions 692*0Sstevel@tonic-gatedocumented in doc/openssl.txt and with examples in demos/pkcs12. The 693*0Sstevel@tonic-gate'pkcs12' application has to use the macros because it prints out 694*0Sstevel@tonic-gatedebugging information. 695*0Sstevel@tonic-gate 696*0Sstevel@tonic-gate 697*0Sstevel@tonic-gate* I've called <some function> and it fails, why? 698*0Sstevel@tonic-gate 699*0Sstevel@tonic-gateBefore submitting a report or asking in one of the mailing lists, you 700*0Sstevel@tonic-gateshould try to determine the cause. In particular, you should call 701*0Sstevel@tonic-gateERR_print_errors() or ERR_print_errors_fp() after the failed call 702*0Sstevel@tonic-gateand see if the message helps. Note that the problem may occur earlier 703*0Sstevel@tonic-gatethan you think -- you should check for errors after every call where 704*0Sstevel@tonic-gateit is possible, otherwise the actual problem may be hidden because 705*0Sstevel@tonic-gatesome OpenSSL functions clear the error state. 706*0Sstevel@tonic-gate 707*0Sstevel@tonic-gate 708*0Sstevel@tonic-gate* I just get a load of numbers for the error output, what do they mean? 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gateThe actual format is described in the ERR_print_errors() manual page. 711*0Sstevel@tonic-gateYou should call the function ERR_load_crypto_strings() before hand and 712*0Sstevel@tonic-gatethe message will be output in text form. If you can't do this (for example 713*0Sstevel@tonic-gateit is a pre-compiled binary) you can use the errstr utility on the error 714*0Sstevel@tonic-gatecode itself (the hex digits after the second colon). 715*0Sstevel@tonic-gate 716*0Sstevel@tonic-gate 717*0Sstevel@tonic-gate* Why do I get errors about unknown algorithms? 718*0Sstevel@tonic-gate 719*0Sstevel@tonic-gateThis can happen under several circumstances such as reading in an 720*0Sstevel@tonic-gateencrypted private key or attempting to decrypt a PKCS#12 file. The cause 721*0Sstevel@tonic-gateis forgetting to load OpenSSL's table of algorithms with 722*0Sstevel@tonic-gateOpenSSL_add_all_algorithms(). See the manual page for more information. 723*0Sstevel@tonic-gate 724*0Sstevel@tonic-gate 725*0Sstevel@tonic-gate* Why can't the OpenSSH configure script detect OpenSSL? 726*0Sstevel@tonic-gate 727*0Sstevel@tonic-gateSeveral reasons for problems with the automatic detection exist. 728*0Sstevel@tonic-gateOpenSSH requires at least version 0.9.5a of the OpenSSL libraries. 729*0Sstevel@tonic-gateSometimes the distribution has installed an older version in the system 730*0Sstevel@tonic-gatelocations that is detected instead of a new one installed. The OpenSSL 731*0Sstevel@tonic-gatelibrary might have been compiled for another CPU or another mode (32/64 bits). 732*0Sstevel@tonic-gatePermissions might be wrong. 733*0Sstevel@tonic-gate 734*0Sstevel@tonic-gateThe general answer is to check the config.log file generated when running 735*0Sstevel@tonic-gatethe OpenSSH configure script. It should contain the detailed information 736*0Sstevel@tonic-gateon why the OpenSSL library was not detected or considered incompatible. 737*0Sstevel@tonic-gate 738*0Sstevel@tonic-gate 739*0Sstevel@tonic-gate* Can I use OpenSSL's SSL library with non-blocking I/O? 740*0Sstevel@tonic-gate 741*0Sstevel@tonic-gateYes; make sure to read the SSL_get_error(3) manual page! 742*0Sstevel@tonic-gate 743*0Sstevel@tonic-gateA pitfall to avoid: Don't assume that SSL_read() will just read from 744*0Sstevel@tonic-gatethe underlying transport or that SSL_write() will just write to it -- 745*0Sstevel@tonic-gateit is also possible that SSL_write() cannot do any useful work until 746*0Sstevel@tonic-gatethere is data to read, or that SSL_read() cannot do anything until it 747*0Sstevel@tonic-gateis possible to send data. One reason for this is that the peer may 748*0Sstevel@tonic-gaterequest a new TLS/SSL handshake at any time during the protocol, 749*0Sstevel@tonic-gaterequiring a bi-directional message exchange; both SSL_read() and 750*0Sstevel@tonic-gateSSL_write() will try to continue any pending handshake. 751*0Sstevel@tonic-gate 752*0Sstevel@tonic-gate 753*0Sstevel@tonic-gate* Why doesn't my server application receive a client certificate? 754*0Sstevel@tonic-gate 755*0Sstevel@tonic-gateDue to the TLS protocol definition, a client will only send a certificate, 756*0Sstevel@tonic-gateif explicitly asked by the server. Use the SSL_VERIFY_PEER flag of the 757*0Sstevel@tonic-gateSSL_CTX_set_verify() function to enable the use of client certificates. 758*0Sstevel@tonic-gate 759*0Sstevel@tonic-gate 760*0Sstevel@tonic-gate* Why does compilation fail due to an undefined symbol NID_uniqueIdentifier? 761*0Sstevel@tonic-gate 762*0Sstevel@tonic-gateFor OpenSSL 0.9.7 the OID table was extended and corrected. In earlier 763*0Sstevel@tonic-gateversions, uniqueIdentifier was incorrectly used for X.509 certificates. 764*0Sstevel@tonic-gateThe correct name according to RFC2256 (LDAP) is x500UniqueIdentifier. 765*0Sstevel@tonic-gateChange your code to use the new name when compiling against OpenSSL 0.9.7. 766*0Sstevel@tonic-gate 767*0Sstevel@tonic-gate 768*0Sstevel@tonic-gate=============================================================================== 769*0Sstevel@tonic-gate 770