CA.pl.pod 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. =pod
  2. =head1 NAME
  3. CA.pl - friendlier interface for OpenSSL certificate programs
  4. =head1 SYNOPSIS
  5. B<CA.pl>
  6. B<-?> |
  7. B<-h> |
  8. B<-help>
  9. B<CA.pl>
  10. B<-newcert> |
  11. B<-newreq> |
  12. B<-newreq-nodes> |
  13. B<-xsign> |
  14. B<-sign> |
  15. B<-signCA> |
  16. B<-signcert> |
  17. B<-crl> |
  18. B<-newca>
  19. [B<-extra-I<cmd>> I<parameter>]
  20. B<CA.pl> B<-pkcs12> [B<-extra-pkcs12> I<parameter>] [I<certname>]
  21. B<CA.pl> B<-verify> [B<-extra-verify> I<parameter>] I<certfile> ...
  22. B<CA.pl> B<-revoke> [B<-extra-ca> I<parameter>] I<certfile> [I<reason>]
  23. =head1 DESCRIPTION
  24. The B<CA.pl> script is a perl script that supplies the relevant command line
  25. arguments to the L<openssl(1)> command for some common certificate operations.
  26. It is intended to simplify the process of certificate creation and management
  27. by the use of some simple options.
  28. The script is intended as a simple front end for the L<openssl(1)> program for
  29. use by a beginner. Its behaviour isn't always what is wanted. For more control
  30. over the behaviour of the certificate commands call the L<openssl(1)> command
  31. directly.
  32. Most of the filenames mentioned below can be modified by editing the
  33. B<CA.pl> script.
  34. Under some environments it may not be possible to run the B<CA.pl> script
  35. directly (for example Win32) and the default configuration file location may
  36. be wrong. In this case the command:
  37. perl -S CA.pl
  38. can be used and the B<OPENSSL_CONF> environment variable can be set to point to
  39. the correct path of the configuration file.
  40. =head1 OPTIONS
  41. =over 4
  42. =item B<?>, B<-h>, B<-help>
  43. Prints a usage message.
  44. =item B<-newcert>
  45. Creates a new self signed certificate. The private key is written to the file
  46. F<newkey.pem> and the request written to the file F<newreq.pem>.
  47. Invokes L<openssl-req(1)>.
  48. =item B<-newreq>
  49. Creates a new certificate request. The private key is written to the file
  50. F<newkey.pem> and the request written to the file F<newreq.pem>.
  51. Executes L<openssl-req(1)> under the hood.
  52. =item B<-newreq-nodes>
  53. Is like B<-newreq> except that the private key will not be encrypted.
  54. Uses L<openssl-req(1)>.
  55. =item B<-newca>
  56. Creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
  57. and B<-xsign> options). The user is prompted to enter the filename of the CA
  58. certificates (which should also contain the private key) or by hitting ENTER
  59. details of the CA will be prompted for. The relevant files and directories
  60. are created in a directory called F<demoCA> in the current directory.
  61. Uses L<openssl-req(1)> and L<openssl-ca(1)>.
  62. If the F<demoCA> directory already exists then the B<-newca> command will not
  63. overwrite it and will do nothing. This can happen if a previous call using
  64. the B<-newca> option terminated abnormally. To get the correct behaviour
  65. delete the directory if it already exists.
  66. =item B<-pkcs12>
  67. Create a PKCS#12 file containing the user certificate, private key and CA
  68. certificate. It expects the user certificate and private key to be in the
  69. file F<newcert.pem> and the CA certificate to be in the file F<demoCA/cacert.pem>,
  70. it creates a file F<newcert.p12>. This command can thus be called after the
  71. B<-sign> option. The PKCS#12 file can be imported directly into a browser.
  72. If there is an additional argument on the command line it will be used as the
  73. "friendly name" for the certificate (which is typically displayed in the browser
  74. list box), otherwise the name "My Certificate" is used.
  75. Delegates work to L<openssl-pkcs12(1)>.
  76. =item B<-sign>, B<-signcert>, B<-xsign>
  77. Calls the L<openssl-ca(1)> command to sign a certificate request. It expects the
  78. request to be in the file F<newreq.pem>. The new certificate is written to the
  79. file F<newcert.pem> except in the case of the B<-xsign> option when it is
  80. written to standard output.
  81. =item B<-signCA>
  82. This option is the same as the B<-sign> option except it uses the
  83. configuration file section B<v3_ca> and so makes the signed request a
  84. valid CA certificate. This is useful when creating intermediate CA from
  85. a root CA. Extra params are passed to L<openssl-ca(1)>.
  86. =item B<-signcert>
  87. This option is the same as B<-sign> except it expects a self signed certificate
  88. to be present in the file F<newreq.pem>.
  89. Extra params are passed to L<openssl-x509(1)> and L<openssl-ca(1)>.
  90. =item B<-crl>
  91. Generate a CRL. Executes L<openssl-ca(1)>.
  92. =item B<-revoke> I<certfile> [I<reason>]
  93. Revoke the certificate contained in the specified B<certfile>. An optional
  94. reason may be specified, and must be one of: B<unspecified>,
  95. B<keyCompromise>, B<CACompromise>, B<affiliationChanged>, B<superseded>,
  96. B<cessationOfOperation>, B<certificateHold>, or B<removeFromCRL>.
  97. Leverages L<openssl-ca(1)>.
  98. =item B<-verify>
  99. Verifies certificates against the CA certificate for F<demoCA>. If no
  100. certificates are specified on the command line it tries to verify the file
  101. F<newcert.pem>. Invokes L<openssl-verify(1)>.
  102. =item B<-extra-I<cmd>> I<parameter>
  103. For each option B<extra-I<cmd>>, pass I<parameter> to the L<openssl(1)>
  104. sub-command with the same name as I<cmd>, if that sub-command is invoked.
  105. For example, if L<openssl-req(1)> is invoked, the I<parameter> given with
  106. B<-extra-req> will be passed to it.
  107. For multi-word parameters, either repeat the option or quote the I<parameters>
  108. so it looks like one word to your shell.
  109. See the individual command documentation for more information.
  110. =back
  111. =head1 EXAMPLES
  112. Create a CA hierarchy:
  113. CA.pl -newca
  114. Complete certificate creation example: create a CA, create a request, sign
  115. the request and finally create a PKCS#12 file containing it.
  116. CA.pl -newca
  117. CA.pl -newreq
  118. CA.pl -sign
  119. CA.pl -pkcs12 "My Test Certificate"
  120. =head1 ENVIRONMENT
  121. The environment variable B<OPENSSL> may be used to specify the name of
  122. the OpenSSL program. It can be a full pathname, or a relative one.
  123. The environment variable B<OPENSSL_CONFIG> may be used to specify a
  124. configuration option and value to the B<req> and B<ca> commands invoked by
  125. this script. It's value should be the option and pathname, as in
  126. C<-config /path/to/conf-file>.
  127. =head1 SEE ALSO
  128. L<openssl(1)>,
  129. L<openssl-x509(1)>,
  130. L<openssl-ca(1)>,
  131. L<openssl-req(1)>,
  132. L<openssl-pkcs12(1)>,
  133. L<config(5)>
  134. =head1 COPYRIGHT
  135. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  136. Licensed under the Apache License 2.0 (the "License"). You may not use
  137. this file except in compliance with the License. You can obtain a copy
  138. in the file LICENSE in the source distribution or at
  139. L<https://www.openssl.org/source/license.html>.
  140. =cut