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