1*ebfedea0SLionel Sambuc 2*ebfedea0SLionel Sambuc=pod 3*ebfedea0SLionel Sambuc 4*ebfedea0SLionel Sambuc=head1 NAME 5*ebfedea0SLionel Sambuc 6*ebfedea0SLionel SambucCA.pl - friendlier interface for OpenSSL certificate programs 7*ebfedea0SLionel Sambuc 8*ebfedea0SLionel Sambuc=head1 SYNOPSIS 9*ebfedea0SLionel Sambuc 10*ebfedea0SLionel SambucB<CA.pl> 11*ebfedea0SLionel Sambuc[B<-?>] 12*ebfedea0SLionel Sambuc[B<-h>] 13*ebfedea0SLionel Sambuc[B<-help>] 14*ebfedea0SLionel Sambuc[B<-newcert>] 15*ebfedea0SLionel Sambuc[B<-newreq>] 16*ebfedea0SLionel Sambuc[B<-newreq-nodes>] 17*ebfedea0SLionel Sambuc[B<-newca>] 18*ebfedea0SLionel Sambuc[B<-xsign>] 19*ebfedea0SLionel Sambuc[B<-sign>] 20*ebfedea0SLionel Sambuc[B<-signreq>] 21*ebfedea0SLionel Sambuc[B<-signcert>] 22*ebfedea0SLionel Sambuc[B<-verify>] 23*ebfedea0SLionel Sambuc[B<files>] 24*ebfedea0SLionel Sambuc 25*ebfedea0SLionel Sambuc=head1 DESCRIPTION 26*ebfedea0SLionel Sambuc 27*ebfedea0SLionel SambucThe B<CA.pl> script is a perl script that supplies the relevant command line 28*ebfedea0SLionel Sambucarguments to the B<openssl> command for some common certificate operations. 29*ebfedea0SLionel SambucIt is intended to simplify the process of certificate creation and management 30*ebfedea0SLionel Sambucby the use of some simple options. 31*ebfedea0SLionel Sambuc 32*ebfedea0SLionel Sambuc=head1 COMMAND OPTIONS 33*ebfedea0SLionel Sambuc 34*ebfedea0SLionel Sambuc=over 4 35*ebfedea0SLionel Sambuc 36*ebfedea0SLionel Sambuc=item B<?>, B<-h>, B<-help> 37*ebfedea0SLionel Sambuc 38*ebfedea0SLionel Sambucprints a usage message. 39*ebfedea0SLionel Sambuc 40*ebfedea0SLionel Sambuc=item B<-newcert> 41*ebfedea0SLionel Sambuc 42*ebfedea0SLionel Sambuccreates a new self signed certificate. The private key is written to the file 43*ebfedea0SLionel Sambuc"newkey.pem" and the request written to the file "newreq.pem". 44*ebfedea0SLionel Sambuc 45*ebfedea0SLionel Sambuc=item B<-newreq> 46*ebfedea0SLionel Sambuc 47*ebfedea0SLionel Sambuccreates a new certificate request. The private key is written to the file 48*ebfedea0SLionel Sambuc"newkey.pem" and the request written to the file "newreq.pem". 49*ebfedea0SLionel Sambuc 50*ebfedea0SLionel Sambuc=item B<-newreq-nodes> 51*ebfedea0SLionel Sambuc 52*ebfedea0SLionel Sambucis like B<-newreq> except that the private key will not be encrypted. 53*ebfedea0SLionel Sambuc 54*ebfedea0SLionel Sambuc=item B<-newca> 55*ebfedea0SLionel Sambuc 56*ebfedea0SLionel Sambuccreates a new CA hierarchy for use with the B<ca> program (or the B<-signcert> 57*ebfedea0SLionel Sambucand B<-xsign> options). The user is prompted to enter the filename of the CA 58*ebfedea0SLionel Sambuccertificates (which should also contain the private key) or by hitting ENTER 59*ebfedea0SLionel Sambucdetails of the CA will be prompted for. The relevant files and directories 60*ebfedea0SLionel Sambucare created in a directory called "demoCA" in the current directory. 61*ebfedea0SLionel Sambuc 62*ebfedea0SLionel Sambuc=item B<-pkcs12> 63*ebfedea0SLionel Sambuc 64*ebfedea0SLionel Sambuccreate a PKCS#12 file containing the user certificate, private key and CA 65*ebfedea0SLionel Sambuccertificate. It expects the user certificate and private key to be in the 66*ebfedea0SLionel Sambucfile "newcert.pem" and the CA certificate to be in the file demoCA/cacert.pem, 67*ebfedea0SLionel Sambucit creates a file "newcert.p12". This command can thus be called after the 68*ebfedea0SLionel SambucB<-sign> option. The PKCS#12 file can be imported directly into a browser. 69*ebfedea0SLionel SambucIf there is an additional argument on the command line it will be used as the 70*ebfedea0SLionel Sambuc"friendly name" for the certificate (which is typically displayed in the browser 71*ebfedea0SLionel Sambuclist box), otherwise the name "My Certificate" is used. 72*ebfedea0SLionel Sambuc 73*ebfedea0SLionel Sambuc=item B<-sign>, B<-signreq>, B<-xsign> 74*ebfedea0SLionel Sambuc 75*ebfedea0SLionel Sambuccalls the B<ca> program to sign a certificate request. It expects the request 76*ebfedea0SLionel Sambucto be in the file "newreq.pem". The new certificate is written to the file 77*ebfedea0SLionel Sambuc"newcert.pem" except in the case of the B<-xsign> option when it is written 78*ebfedea0SLionel Sambucto standard output. 79*ebfedea0SLionel Sambuc 80*ebfedea0SLionel Sambuc 81*ebfedea0SLionel Sambuc=item B<-signCA> 82*ebfedea0SLionel Sambuc 83*ebfedea0SLionel Sambucthis option is the same as the B<-signreq> option except it uses the configuration 84*ebfedea0SLionel Sambucfile section B<v3_ca> and so makes the signed request a valid CA certificate. This 85*ebfedea0SLionel Sambucis useful when creating intermediate CA from a root CA. 86*ebfedea0SLionel Sambuc 87*ebfedea0SLionel Sambuc=item B<-signcert> 88*ebfedea0SLionel Sambuc 89*ebfedea0SLionel Sambucthis option is the same as B<-sign> except it expects a self signed certificate 90*ebfedea0SLionel Sambucto be present in the file "newreq.pem". 91*ebfedea0SLionel Sambuc 92*ebfedea0SLionel Sambuc=item B<-verify> 93*ebfedea0SLionel Sambuc 94*ebfedea0SLionel Sambucverifies certificates against the CA certificate for "demoCA". If no certificates 95*ebfedea0SLionel Sambucare specified on the command line it tries to verify the file "newcert.pem". 96*ebfedea0SLionel Sambuc 97*ebfedea0SLionel Sambuc=item B<files> 98*ebfedea0SLionel Sambuc 99*ebfedea0SLionel Sambucone or more optional certificate file names for use with the B<-verify> command. 100*ebfedea0SLionel Sambuc 101*ebfedea0SLionel Sambuc=back 102*ebfedea0SLionel Sambuc 103*ebfedea0SLionel Sambuc=head1 EXAMPLES 104*ebfedea0SLionel Sambuc 105*ebfedea0SLionel SambucCreate a CA hierarchy: 106*ebfedea0SLionel Sambuc 107*ebfedea0SLionel Sambuc CA.pl -newca 108*ebfedea0SLionel Sambuc 109*ebfedea0SLionel SambucComplete certificate creation example: create a CA, create a request, sign 110*ebfedea0SLionel Sambucthe request and finally create a PKCS#12 file containing it. 111*ebfedea0SLionel Sambuc 112*ebfedea0SLionel Sambuc CA.pl -newca 113*ebfedea0SLionel Sambuc CA.pl -newreq 114*ebfedea0SLionel Sambuc CA.pl -signreq 115*ebfedea0SLionel Sambuc CA.pl -pkcs12 "My Test Certificate" 116*ebfedea0SLionel Sambuc 117*ebfedea0SLionel Sambuc=head1 DSA CERTIFICATES 118*ebfedea0SLionel Sambuc 119*ebfedea0SLionel SambucAlthough the B<CA.pl> creates RSA CAs and requests it is still possible to 120*ebfedea0SLionel Sambucuse it with DSA certificates and requests using the L<req(1)|req(1)> command 121*ebfedea0SLionel Sambucdirectly. The following example shows the steps that would typically be taken. 122*ebfedea0SLionel Sambuc 123*ebfedea0SLionel SambucCreate some DSA parameters: 124*ebfedea0SLionel Sambuc 125*ebfedea0SLionel Sambuc openssl dsaparam -out dsap.pem 1024 126*ebfedea0SLionel Sambuc 127*ebfedea0SLionel SambucCreate a DSA CA certificate and private key: 128*ebfedea0SLionel Sambuc 129*ebfedea0SLionel Sambuc openssl req -x509 -newkey dsa:dsap.pem -keyout cacert.pem -out cacert.pem 130*ebfedea0SLionel Sambuc 131*ebfedea0SLionel SambucCreate the CA directories and files: 132*ebfedea0SLionel Sambuc 133*ebfedea0SLionel Sambuc CA.pl -newca 134*ebfedea0SLionel Sambuc 135*ebfedea0SLionel Sambucenter cacert.pem when prompted for the CA file name. 136*ebfedea0SLionel Sambuc 137*ebfedea0SLionel SambucCreate a DSA certificate request and private key (a different set of parameters 138*ebfedea0SLionel Sambuccan optionally be created first): 139*ebfedea0SLionel Sambuc 140*ebfedea0SLionel Sambuc openssl req -out newreq.pem -newkey dsa:dsap.pem 141*ebfedea0SLionel Sambuc 142*ebfedea0SLionel SambucSign the request: 143*ebfedea0SLionel Sambuc 144*ebfedea0SLionel Sambuc CA.pl -signreq 145*ebfedea0SLionel Sambuc 146*ebfedea0SLionel Sambuc=head1 NOTES 147*ebfedea0SLionel Sambuc 148*ebfedea0SLionel SambucMost of the filenames mentioned can be modified by editing the B<CA.pl> script. 149*ebfedea0SLionel Sambuc 150*ebfedea0SLionel SambucIf the demoCA directory already exists then the B<-newca> command will not 151*ebfedea0SLionel Sambucoverwrite it and will do nothing. This can happen if a previous call using 152*ebfedea0SLionel Sambucthe B<-newca> option terminated abnormally. To get the correct behaviour 153*ebfedea0SLionel Sambucdelete the demoCA directory if it already exists. 154*ebfedea0SLionel Sambuc 155*ebfedea0SLionel SambucUnder some environments it may not be possible to run the B<CA.pl> script 156*ebfedea0SLionel Sambucdirectly (for example Win32) and the default configuration file location may 157*ebfedea0SLionel Sambucbe wrong. In this case the command: 158*ebfedea0SLionel Sambuc 159*ebfedea0SLionel Sambuc perl -S CA.pl 160*ebfedea0SLionel Sambuc 161*ebfedea0SLionel Sambuccan be used and the B<OPENSSL_CONF> environment variable changed to point to 162*ebfedea0SLionel Sambucthe correct path of the configuration file "openssl.cnf". 163*ebfedea0SLionel Sambuc 164*ebfedea0SLionel SambucThe script is intended as a simple front end for the B<openssl> program for use 165*ebfedea0SLionel Sambucby a beginner. Its behaviour isn't always what is wanted. For more control over the 166*ebfedea0SLionel Sambucbehaviour of the certificate commands call the B<openssl> command directly. 167*ebfedea0SLionel Sambuc 168*ebfedea0SLionel Sambuc=head1 ENVIRONMENT VARIABLES 169*ebfedea0SLionel Sambuc 170*ebfedea0SLionel SambucThe variable B<OPENSSL_CONF> if defined allows an alternative configuration 171*ebfedea0SLionel Sambucfile location to be specified, it should contain the full path to the 172*ebfedea0SLionel Sambucconfiguration file, not just its directory. 173*ebfedea0SLionel Sambuc 174*ebfedea0SLionel Sambuc=head1 SEE ALSO 175*ebfedea0SLionel Sambuc 176*ebfedea0SLionel SambucL<x509(1)|x509(1)>, L<ca(1)|ca(1)>, L<req(1)|req(1)>, L<pkcs12(1)|pkcs12(1)>, 177*ebfedea0SLionel SambucL<config(5)|config(5)> 178*ebfedea0SLionel Sambuc 179*ebfedea0SLionel Sambuc=cut 180