certificates.txt 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <DRAFT!>
  2. HOWTO certificates
  3. 1. Introduction
  4. How you handle certificates depends a great deal on what your role is.
  5. Your role can be one or several of:
  6. - User of some client application
  7. - User of some server application
  8. - Certificate authority
  9. This file is for users who wish to get a certificate of their own.
  10. Certificate authorities should read https://www.openssl.org/docs/apps/ca.html.
  11. In all the cases shown below, the standard configuration file, as
  12. compiled into openssl, will be used. You may find it in /etc/,
  13. /usr/local/ssl/ or somewhere else. By default the file is named
  14. openssl.cnf and is described at https://www.openssl.org/docs/apps/config.html.
  15. You can specify a different configuration file using the
  16. '-config {file}' argument with the commands shown below.
  17. 2. Relationship with keys
  18. Certificates are related to public key cryptography by containing a
  19. public key. To be useful, there must be a corresponding private key
  20. somewhere. With OpenSSL, public keys are easily derived from private
  21. keys, so before you create a certificate or a certificate request, you
  22. need to create a private key.
  23. Private keys are generated with 'openssl genrsa -out privkey.pem' if
  24. you want an RSA private key, or if you want a DSA private key:
  25. 'openssl dsaparam -out dsaparam.pem 2048; openssl gendsa -out privkey.pem dsaparam.pem'.
  26. The private keys created by these commands are not passphrase protected;
  27. it might or might not be the desirable thing. Further information on how to
  28. create private keys can be found at https://www.openssl.org/docs/HOWTO/keys.txt.
  29. The rest of this text assumes you have a private key in the file privkey.pem.
  30. 3. Creating a certificate request
  31. To create a certificate, you need to start with a certificate request
  32. (or, as some certificate authorities like to put it, "certificate
  33. signing request", since that's exactly what they do, they sign it and
  34. give you the result back, thus making it authentic according to their
  35. policies). A certificate request is sent to a certificate authority
  36. to get it signed into a certificate. You can also sign the certificate
  37. yourself if you have your own certificate authority or create a
  38. self-signed certificate (typically for testing purpose).
  39. The certificate request is created like this:
  40. openssl req -new -key privkey.pem -out cert.csr
  41. Now, cert.csr can be sent to the certificate authority, if they can
  42. handle files in PEM format. If not, use the extra argument '-outform'
  43. followed by the keyword for the format to use (see another HOWTO
  44. <formats.txt?>). In some cases, -outform does not let you output the
  45. certificate request in the right format and you will have to use one
  46. of the various other commands that are exposed by openssl (or get
  47. creative and use a combination of tools).
  48. The certificate authority performs various checks (according to their
  49. policies) and usually waits for payment from you. Once that is
  50. complete, they send you your new certificate.
  51. Section 5 will tell you more on how to handle the certificate you
  52. received.
  53. 4. Creating a self-signed test certificate
  54. You can create a self-signed certificate if you don't want to deal
  55. with a certificate authority, or if you just want to create a test
  56. certificate for yourself. This is similar to creating a certificate
  57. request, but creates a certificate instead of a certificate request.
  58. This is NOT the recommended way to create a CA certificate, see
  59. https://www.openssl.org/docs/apps/ca.html.
  60. openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095
  61. 5. What to do with the certificate
  62. If you created everything yourself, or if the certificate authority
  63. was kind enough, your certificate is a raw DER thing in PEM format.
  64. Your key most definitely is if you have followed the examples above.
  65. However, some (most?) certificate authorities will encode them with
  66. things like PKCS7 or PKCS12, or something else. Depending on your
  67. applications, this may be perfectly OK, it all depends on what they
  68. know how to decode. If not, there are a number of OpenSSL tools to
  69. convert between some (most?) formats.
  70. So, depending on your application, you may have to convert your
  71. certificate and your key to various formats, most often also putting
  72. them together into one file. The ways to do this is described in
  73. another HOWTO <formats.txt?>, I will just mention the simplest case.
  74. In the case of a raw DER thing in PEM format, and assuming that's all
  75. right for your applications, simply concatenating the certificate and
  76. the key into a new file and using that one should be enough. With
  77. some applications, you don't even have to do that.
  78. By now, you have your certificate and your private key and can start
  79. using applications that depend on it.
  80. --
  81. Richard Levitte