2
0

CA.pl.pod 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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<-newcert>]
  10. [B<-newreq>]
  11. [B<-newreq-nodes>]
  12. [B<-newca>]
  13. [B<-xsign>]
  14. [B<-sign>]
  15. [B<-signreq>]
  16. [B<-signcert>]
  17. [B<-verify>]
  18. [B<files>]
  19. =head1 DESCRIPTION
  20. The B<CA.pl> script is a perl script that supplies the relevant command line
  21. arguments to the B<openssl> command for some common certificate operations.
  22. It is intended to simplify the process of certificate creation and management
  23. by the use of some simple options.
  24. =head1 COMMAND OPTIONS
  25. =over 4
  26. =item B<?>, B<-h>, B<-help>
  27. prints a usage message.
  28. =item B<-newcert>
  29. creates a new self signed certificate. The private key and certificate are
  30. written to the file "newreq.pem".
  31. =item B<-newreq>
  32. creates a new certificate request. The private key and request are
  33. written to the file "newreq.pem".
  34. =item B<-newreq-nodes>
  35. is like B<-newreq> except that the private key will not be encrypted.
  36. =item B<-newca>
  37. creates a new CA hierarchy for use with the B<ca> program (or the B<-signcert>
  38. and B<-xsign> options). The user is prompted to enter the filename of the CA
  39. certificates (which should also contain the private key) or by hitting ENTER
  40. details of the CA will be prompted for. The relevant files and directories
  41. are created in a directory called "demoCA" in the current directory.
  42. =item B<-pkcs12>
  43. create a PKCS#12 file containing the user certificate, private key and CA
  44. certificate. It expects the user certificate and private key to be in the
  45. file "newcert.pem" and the CA certificate to be in the file demoCA/cacert.pem,
  46. it creates a file "newcert.p12". This command can thus be called after the
  47. B<-sign> option. The PKCS#12 file can be imported directly into a browser.
  48. If there is an additional argument on the command line it will be used as the
  49. "friendly name" for the certificate (which is typically displayed in the browser
  50. list box), otherwise the name "My Certificate" is used.
  51. =item B<-sign>, B<-signreq>, B<-xsign>
  52. calls the B<ca> program to sign a certificate request. It expects the request
  53. to be in the file "newreq.pem". The new certificate is written to the file
  54. "newcert.pem" except in the case of the B<-xsign> option when it is written
  55. to standard output.
  56. =item B<-signCA>
  57. this option is the same as the B<-signreq> option except it uses the configuration
  58. file section B<v3_ca> and so makes the signed request a valid CA certificate. This
  59. is useful when creating intermediate CA from a root CA.
  60. =item B<-signcert>
  61. this option is the same as B<-sign> except it expects a self signed certificate
  62. to be present in the file "newreq.pem".
  63. =item B<-verify>
  64. verifies certificates against the CA certificate for "demoCA". If no certificates
  65. are specified on the command line it tries to verify the file "newcert.pem".
  66. =item B<files>
  67. one or more optional certificate file names for use with the B<-verify> command.
  68. =back
  69. =head1 EXAMPLES
  70. Create a CA hierarchy:
  71. CA.pl -newca
  72. Complete certificate creation example: create a CA, create a request, sign
  73. the request and finally create a PKCS#12 file containing it.
  74. CA.pl -newca
  75. CA.pl -newreq
  76. CA.pl -signreq
  77. CA.pl -pkcs12 "My Test Certificate"
  78. =head1 DSA CERTIFICATES
  79. Although the B<CA.pl> creates RSA CAs and requests it is still possible to
  80. use it with DSA certificates and requests using the L<req(1)|req(1)> command
  81. directly. The following example shows the steps that would typically be taken.
  82. Create some DSA parameters:
  83. openssl dsaparam -out dsap.pem 1024
  84. Create a DSA CA certificate and private key:
  85. openssl req -x509 -newkey dsa:dsap.pem -keyout cacert.pem -out cacert.pem
  86. Create the CA directories and files:
  87. CA.pl -newca
  88. enter cacert.pem when prompted for the CA file name.
  89. Create a DSA certificate request and private key (a different set of parameters
  90. can optionally be created first):
  91. openssl req -out newreq.pem -newkey dsa:dsap.pem
  92. Sign the request:
  93. CA.pl -signreq
  94. =head1 NOTES
  95. Most of the filenames mentioned can be modified by editing the B<CA.pl> script.
  96. If the demoCA directory already exists then the B<-newca> command will not
  97. overwrite it and will do nothing. This can happen if a previous call using
  98. the B<-newca> option terminated abnormally. To get the correct behaviour
  99. delete the demoCA directory if it already exists.
  100. Under some environments it may not be possible to run the B<CA.pl> script
  101. directly (for example Win32) and the default configuration file location may
  102. be wrong. In this case the command:
  103. perl -S CA.pl
  104. can be used and the B<OPENSSL_CONF> environment variable changed to point to
  105. the correct path of the configuration file "openssl.cnf".
  106. The script is intended as a simple front end for the B<openssl> program for use
  107. by a beginner. Its behaviour isn't always what is wanted. For more control over the
  108. behaviour of the certificate commands call the B<openssl> command directly.
  109. =head1 ENVIRONMENT VARIABLES
  110. The variable B<OPENSSL_CONF> if defined allows an alternative configuration
  111. file location to be specified, it should contain the full path to the
  112. configuration file, not just its directory.
  113. =head1 SEE ALSO
  114. L<x509(1)|x509(1)>, L<ca(1)|ca(1)>, L<req(1)|req(1)>, L<pkcs12(1)|pkcs12(1)>,
  115. L<config(5)|config(5)>
  116. =cut