README.rootcerts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. DOS/Windows-oriented notes on Root Certificates
  2. To use certificates or a cert bundle within an SSL enabled
  3. application such as lynx you must place your certificate
  4. files into a known directory, and set the environment
  5. variables to a proper value (e.g. in CONFIG.SYS file).
  6. set SSL_CERT_DIR=x:/usr/local/ssl/certs
  7. set SSL_CERT_FILE=x:/usr/local/ssl/cert.pem
  8. (See "What are root certificates" below.)
  9. Q. Why would I want to install openssl.exe?
  10. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. openssl.exe is used to manage certificates. (See "What are root certificates"
  12. below.)
  13. Q. How to install openssl.exe?
  14. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. Put openssl.exe in a directory in your PATH and the DLLs to a directory
  16. in your LIBPATH.
  17. Copy conf\openssl.cnf.demoCA to a directory of your
  18. choice, rename it to openssl.conf and set the environment variable
  19. OPENSSL_CONF by putting
  20. SET OPENSSL_CONF=<your-directory>\openssl.cnf
  21. into CONFIG.SYS.
  22. Q. Why is this document so paranoid?
  23. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. If you want to use OpenSSL, then probably your Internet transactions have
  25. *real* monetary value embedded in them. And as usual, the security is as good
  26. as the weakest link. This document unravels only the tip of the iceberg
  27. of what can go wrong with improperly established "secure" connections. And
  28. given the monetary value involved, "bad guys" have a high incentive to exploit
  29. the weakest links. As experience shows, do not underestimate the intelligence
  30. of bad guys...
  31. Really, with security, a little knowledge is a dangerous thing; one can
  32. suspect that many people, if they really understood the trust structures
  33. associated with SSL, would be rather careful about checking the details
  34. of certificates.
  35. Q. What are root certificates?
  36. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. Making a secure connection is like sending your valuables (for storage or
  38. consumption) to somebody who agreed to be at a prearranged place. To
  39. guard the valuables on the way there, you can ask for a police escort; this is
  40. what https:// connections are about. However, it does not make any sense to
  41. have an escort if the goods are transfered to a random person who happens to be
  42. at this place; one needs to certify the identity of the receiver as well.
  43. The certification process is a chain; when site A wants to certify that it is
  44. actually what it claims, it actually says "Check this certificate with site B";
  45. to proceed, one needs to certify that site B is what it claims, so B may
  46. redirect to site C etc. For this process to stop, some sites claim
  47. "You must know my certificate, check it yourself". These certificates are
  48. "root certificates"; one cannot verify such a site unless one has the
  49. certificate for the "end of its certification chain". If you don't have the
  50. relevant root certificate in your local certificates file, it means that
  51. you don't trust anyone to vouch for the authenticity of the site.
  52. So one should have a collection of known certificates from several well-known
  53. sites known as "Root Certification Authorities". Most sites for large-scale
  54. businesses have certificates which will eventually resolve to these places.
  55. Such certicates represent people like Verisign that are in the business of
  56. confirming the identity of servers, etc.
  57. Additionally, since having yourself certified through another site costs,
  58. some sites avoid this cost via presenting "end-of-chain certificates".
  59. One should have a way to obtain these certificates via other means than
  60. insecure Internet connection (e.g., one can walk into the office and copy
  61. the certificate file to a floppy). These are so-called "Self-signed
  62. certificates"; they are "root certificates" as well. The locally-installed
  63. securely obtained copies of such certificates are referred to as
  64. "local certificates". (See 'What is "Snake Oil Ltd."' below.)
  65. If you are presented with a locally-unresolvable root certificate, and you
  66. *believe* that you are really talking to the site, and not someone
  67. in between (who is either completely simulating the site or relaying
  68. your requests onto the real site - called a "man in the middle" attack),
  69. you will still have an encrypted connection. Otherwise, you should act
  70. as though the site was an impostor, unless and until you manage to get
  71. a root certificate from a trustworthy source, and that root certificate
  72. represents someone that you would trust to have vetted the site you
  73. want to connect to.
  74. Local certificates are stored in SSL_CERT_FILE (this "cert bundle", usually
  75. named cert.pem, contains several signatures for "Root Certification
  76. Authorities") and SSL_CERT_DIR (which has a signature per file, and usually
  77. contain local copies of self-signed certificates).
  78. There are three crucial considerations to be added to this picture:
  79. a) While there are ways to ensure that the receivers are who they claim,
  80. there is absolutely no technological way to verify how *trustworthy*
  81. the receiving party is. It does not make sense to secure-send your
  82. valuables to a certified receiver if this receiver is a crook (or will
  83. just keep them later in a publicly accessible place).
  84. b) "VeriSign Syndrome". For the above scheme of "a chain of trust" to work,
  85. the "Root Certification Authorities" should be *very* trustworthy
  86. high-integrity entities. Unfortunately, there are certain doubts that
  87. this is so. E.g., fall 2003, VeriSign started an attack on DNS scheme
  88. which could disrupt the whole architecture of Internet (hijacking *all*
  89. unclaimed Internet addresses and redirecting them to a promotional site;
  90. google for VeriSign DNS hijack).
  91. One major company even issued a Microsoft certificate to a company
  92. other than Microsoft, and there had to be a Windows critical update
  93. to block that certificate.
  94. c) Keep in mind that the "big 2 browsers" are adding an increasing
  95. number of root certificates, and most users fail to realise that they
  96. are putting a trust in the supply chain for the browser to give them
  97. the certificates of reliable organisations (the browser suppliers could
  98. make bad choices, or the browser could have been hacked before you got
  99. it).
  100. Incidentally, standard browsers come with certificates representing
  101. very different levels of identity verification, but most people accept
  102. all of those supplied with the big 2 as equally valid.
  103. Q. How to obtain root certificates?
  104. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  105. Certificate files, such as cert.pem, are security critical; you have to
  106. trust whoever supplies it to you; all your certification process is no more
  107. trustworthy than the site you downloaded cert.pem from. So you shouldn't just
  108. accept any offer.
  109. One way is to copy them from a machine which already obtained them in a secure
  110. way. Another one is to extract them from a web browser which was itself
  111. obtained in a secure way (see "How to extract certificates from Internet
  112. Explorer" below). If anything else fails, obtaining a privately-generated
  113. bundle from third-parties, such as
  114. http://www.kfu.com/~nsayer/encryption/ca-bundle.crt.text
  115. is *not* much better than no certificates at all, but may avoid some warnings
  116. from applications. One of the places which has a bundle is the mod_ssl site.
  117. Q. Should you trust this distribution system?
  118. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119. It is very hard to imagine a situation when the answer is different from
  120. "Absolutely not!".
  121. Indeed, obtaining the certificates is only half of the problem.
  122. The certificates are going to be checked by the SSL library. Can you trust
  123. these executables (DLLs)? Did you obtain the library via a secure connection?
  124. Are you sure that the place you obtained it from has reasonable security
  125. practice, so that the archive could not be tampered with? The latter place
  126. most probably did not build the DLLs themselves; chances are they just
  127. store what a fourth-party supplied them. Was *that* file transfer done via
  128. secure channels? Can you trust this fourth-party so that it did not insert
  129. Trojans?
  130. Chances are that all of these questions are answered "No". There are still
  131. major problems with bootstrapping security via the Internet...
  132. What about the application which uses these DLLs? Do you have any reason to
  133. trust it? What about the OS itself? Did it come from a trustworthy source
  134. via trustworthy channels? Are you sure it was not tampered with?
  135. Q. How to compile and link with OpenSSL libraries?
  136. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137. Put the files from include and lib to your emx directory,
  138. or directories on C_INCLUDE_PATH and LIBRARY_PATH.
  139. Note that openssl should become a subdirectory of your include directory.
  140. If you need .lib files you can create them using emxomf.
  141. The supplied library files link against the new renamed dlls open_ssl and
  142. cryptsll.
  143. See the doc directory for some information and visit
  144. http://www.columbia.edu/~ariel/ssleay/ for more infos.
  145. Q. Why do you need your own keys and certificates?
  146. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  147. There are several situations: having a server which accepts secure connections;
  148. authenticating yourself to a server by means other than login/password,
  149. sending S-Mime crypto-mail, authenticating from a client browser to a server.
  150. In each of these situations one needs keys.
  151. The following sites may be useful:
  152. http://www.pseudonym.org/ssl/ssl_cook.html#environment
  153. http://the.earth.li/~sgtatham/putty/0.53b/htmldoc/Chapter8.html#8.2
  154. Q. How to generate your own keys and certificates?
  155. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  156. There are many ways. A good solution is to use sslRexx. It provides everything
  157. you need. PuTTYgen is a key generator that will work.
  158. Below is a short description of how I made my own Certification Authority,
  159. a Server Key for Apache and a client Key/Certificate for me, signed by my
  160. own CA.
  161. Q. Howto: Root CA (needed to self-sign all certificates)
  162. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  163. Generate a CA-Key and store it in sub-directory private:
  164. openssl genrsa -des3 -out private/MyOwnCA.pem 2048
  165. Make a selfsigned certificate based on above key.
  166. openssl req -new -x509 -days 730 -key private/CAkey.pem -out CAcert.pem
  167. This certificate will expire in 2 years.
  168. Optional: generate text output of this certificate:
  169. openssl x509 -in ./CAcert.pem -text > CAcert.txt
  170. Now you have a key and certificate for your own CA which can be used
  171. to sign user and server keys. The CAcert is also needed to configure
  172. Apache and Netscape. You can/should give away the CA certificate but
  173. never give the CA key to anybody.
  174. Q. Howto: Your Client Certificate/Key
  175. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  176. Generate a private key
  177. ----------------------
  178. openssl genrsa -des3 -out hrom-key.pem 2048
  179. Create a signing request (same command again)
  180. ------------------------
  181. openssl req -new -key hrom-key.pem -out hrom-req.pem
  182. Let the CA sign it (same command again)
  183. ------------------
  184. openssl ca -in hrom-req.pem -out hrom-cert.pem -outdir MyOwnCA/newcerts
  185. After you get back the certificate from the CA, combine it with
  186. your private key and store the result as p12 file. This file can
  187. be imported into your browser. The browser will use this file to present
  188. to a server requiring it for access.
  189. openssl pkcs12 -export -name Hromadka -in hrom-cert.pem -inkey hrom-key.pem -out hrom.p12
  190. Security Notes: Never give your private key to a CA, they only need the
  191. signing request. Never give away your p12 file. Always secure your private
  192. keys with a passphrase.
  193. Q. How to use c_rehash?
  194. ~~~~~~~~~~~~~~~~~~~~~~
  195. One needs a working port of Perl and cp.exe to run this. Set OPENSSL to the
  196. full name of openssl executable. One may also need to change some ':' to
  197. $Config{path_sep}. c_rehash finds certs from enviroment variables and allows
  198. them to be recognized by openssl.
  199. Q. How to extract certificates from Internet Explorer?
  200. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  201. To make your own file of certificates, go to the
  202. "Tools/Internet Options/Content/Certificates/Trusted Root Certificates"
  203. section of IE. Select all the certificates, then "export" to a file.
  204. It will be saved as a PKCS#7 file, with suffix ".p7b". You can call
  205. it "ca_bundle.p7b". Then use openssl to convert it with the command:
  206. "openssl pkcs7 -inform DER -in ca_bundle.p7b -print_certs -text -out cert.pem".
  207. Ask your system administrator to put the file "cert.pem" in the openssl
  208. directory and c_rehash it. Then lynx can check the certificates against the
  209. set of certificates that you (or Microsoft) trusts, and you won't get the
  210. warning message any more.
  211. Q. How to install a self-signed certificate?
  212. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  213. When you would like to trust a self-signed (non-commercial) certificate you will
  214. need to get hold of the actual file. If it's a cert local to your network you
  215. can ask the sysadmin to make it available for download as a link on a webpage.
  216. If such file is not human-readable it's probably DER formatted and will need to
  217. be converted to PEM format to allow openssl to use it.
  218. To convert DER formatted certificates into something openssl can deal with:
  219. Save the cert as site_name.crt in a directory. In that directory, type:
  220. openssl x509 -inform DER -in site_name.crt -outform PEM -out site_name.pem
  221. You can now copy this individual cert into the directory for that and hash the
  222. cert by running c_rehash. A complete discussion of this procedure for unix is
  223. in the document README.sslcerts.