159191Skris 259191Skris=pod 359191Skris 459191Skris=head1 NAME 559191Skris 659191Skrisca - sample minimal CA application 759191Skris 859191Skris=head1 SYNOPSIS 959191Skris 1059191SkrisB<openssl> B<ca> 1159191Skris[B<-verbose>] 1259191Skris[B<-config filename>] 1359191Skris[B<-name section>] 1459191Skris[B<-gencrl>] 1559191Skris[B<-revoke file>] 16269686Sjkim[B<-status serial>] 17269686Sjkim[B<-updatedb>] 18109998Smarkm[B<-crl_reason reason>] 19109998Smarkm[B<-crl_hold instruction>] 20109998Smarkm[B<-crl_compromise time>] 21109998Smarkm[B<-crl_CA_compromise time>] 2259191Skris[B<-crldays days>] 2359191Skris[B<-crlhours hours>] 2459191Skris[B<-crlexts section>] 2559191Skris[B<-startdate date>] 2659191Skris[B<-enddate date>] 2759191Skris[B<-days arg>] 2859191Skris[B<-md arg>] 2959191Skris[B<-policy arg>] 3059191Skris[B<-keyfile arg>] 31269686Sjkim[B<-keyform PEM|DER>] 3259191Skris[B<-key arg>] 3368651Skris[B<-passin arg>] 3459191Skris[B<-cert file>] 35160814Ssimon[B<-selfsign>] 3659191Skris[B<-in file>] 3759191Skris[B<-out file>] 3859191Skris[B<-notext>] 3959191Skris[B<-outdir dir>] 4059191Skris[B<-infiles>] 4159191Skris[B<-spkac file>] 4259191Skris[B<-ss_cert file>] 4359191Skris[B<-preserveDN>] 44109998Smarkm[B<-noemailDN>] 4559191Skris[B<-batch>] 4659191Skris[B<-msie_hack>] 4759191Skris[B<-extensions section>] 48109998Smarkm[B<-extfile section>] 49111147Snectar[B<-engine id>] 50160814Ssimon[B<-subj arg>] 51160814Ssimon[B<-utf8>] 52160814Ssimon[B<-multivalue-rdn>] 5359191Skris 5459191Skris=head1 DESCRIPTION 5559191Skris 5659191SkrisThe B<ca> command is a minimal CA application. It can be used 5759191Skristo sign certificate requests in a variety of forms and generate 5859191SkrisCRLs it also maintains a text database of issued certificates 5959191Skrisand their status. 6059191Skris 6159191SkrisThe options descriptions will be divided into each purpose. 6259191Skris 6359191Skris=head1 CA OPTIONS 6459191Skris 6559191Skris=over 4 6659191Skris 6759191Skris=item B<-config filename> 6859191Skris 6959191Skrisspecifies the configuration file to use. 7059191Skris 7189837Skris=item B<-name section> 7289837Skris 7389837Skrisspecifies the configuration file section to use (overrides 7489837SkrisB<default_ca> in the B<ca> section). 7589837Skris 7659191Skris=item B<-in filename> 7759191Skris 7859191Skrisan input filename containing a single certificate request to be 7959191Skrissigned by the CA. 8059191Skris 8159191Skris=item B<-ss_cert filename> 8259191Skris 8359191Skrisa single self signed certificate to be signed by the CA. 8459191Skris 8559191Skris=item B<-spkac filename> 8659191Skris 8759191Skrisa file containing a single Netscape signed public key and challenge 88109998Smarkmand additional field values to be signed by the CA. See the B<SPKAC FORMAT> 89269686Sjkimsection for information on the required input and output format. 9059191Skris 9159191Skris=item B<-infiles> 9259191Skris 9359191Skrisif present this should be the last option, all subsequent arguments 94237658Sjkimare assumed to be the names of files containing certificate requests. 9559191Skris 9659191Skris=item B<-out filename> 9759191Skris 9859191Skristhe output file to output certificates to. The default is standard 9959191Skrisoutput. The certificate details will also be printed out to this 100269686Sjkimfile in PEM format (except that B<-spkac> outputs DER format). 10159191Skris 10259191Skris=item B<-outdir directory> 10359191Skris 10459191Skristhe directory to output certificates to. The certificate will be 10559191Skriswritten to a filename consisting of the serial number in hex with 10659191Skris".pem" appended. 10759191Skris 10859191Skris=item B<-cert> 10959191Skris 11059191Skristhe CA certificate file. 11159191Skris 11259191Skris=item B<-keyfile filename> 11359191Skris 11459191Skristhe private key to sign requests with. 11559191Skris 116269686Sjkim=item B<-keyform PEM|DER> 117269686Sjkim 118269686Sjkimthe format of the data in the private key file. 119269686SjkimThe default is PEM. 120269686Sjkim 12159191Skris=item B<-key password> 12259191Skris 12359191Skristhe password used to encrypt the private key. Since on some 12459191Skrissystems the command line arguments are visible (e.g. Unix with 12559191Skristhe 'ps' utility) this option should be used with caution. 12659191Skris 127160814Ssimon=item B<-selfsign> 128160814Ssimon 129160814Ssimonindicates the issued certificates are to be signed with the key 130160814Ssimonthe certificate requests were signed with (given with B<-keyfile>). 131160814SsimonCerificate requests signed with a different key are ignored. If 132160814SsimonB<-spkac>, B<-ss_cert> or B<-gencrl> are given, B<-selfsign> is 133160814Ssimonignored. 134160814Ssimon 135160814SsimonA consequence of using B<-selfsign> is that the self-signed 136160814Ssimoncertificate appears among the entries in the certificate database 137160814Ssimon(see the configuration option B<database>), and uses the same 138160814Ssimonserial number counter as all other certificates sign with the 139160814Ssimonself-signed certificate. 140160814Ssimon 14168651Skris=item B<-passin arg> 14268651Skris 14368651Skristhe key password source. For more information about the format of B<arg> 14468651Skrissee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 145109998Smarkm 14659191Skris=item B<-verbose> 14759191Skris 14859191Skristhis prints extra details about the operations being performed. 14959191Skris 15059191Skris=item B<-notext> 15159191Skris 15259191Skrisdon't output the text form of a certificate to the output file. 15359191Skris 15459191Skris=item B<-startdate date> 15559191Skris 15659191Skristhis allows the start date to be explicitly set. The format of the 15759191Skrisdate is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure). 15859191Skris 15959191Skris=item B<-enddate date> 16059191Skris 16159191Skristhis allows the expiry date to be explicitly set. The format of the 16259191Skrisdate is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure). 16359191Skris 16459191Skris=item B<-days arg> 16559191Skris 16659191Skristhe number of days to certify the certificate for. 16759191Skris 16859191Skris=item B<-md alg> 16959191Skris 17059191Skristhe message digest to use. Possible values include md5, sha1 and mdc2. 17159191SkrisThis option also applies to CRLs. 17259191Skris 17359191Skris=item B<-policy arg> 17459191Skris 17559191Skristhis option defines the CA "policy" to use. This is a section in 17659191Skristhe configuration file which decides which fields should be mandatory 17759191Skrisor match the CA certificate. Check out the B<POLICY FORMAT> section 17859191Skrisfor more information. 17959191Skris 18059191Skris=item B<-msie_hack> 18159191Skris 18259191Skristhis is a legacy option to make B<ca> work with very old versions of 18359191Skristhe IE certificate enrollment control "certenr3". It used UniversalStrings 18459191Skrisfor almost everything. Since the old control has various security bugs 18559191Skrisits use is strongly discouraged. The newer control "Xenroll" does not 18659191Skrisneed this option. 18759191Skris 18859191Skris=item B<-preserveDN> 18959191Skris 19059191SkrisNormally the DN order of a certificate is the same as the order of the 19159191Skrisfields in the relevant policy section. When this option is set the order 19259191Skrisis the same as the request. This is largely for compatibility with the 19359191Skrisolder IE enrollment control which would only accept certificates if their 19459191SkrisDNs match the order of the request. This is not needed for Xenroll. 19559191Skris 196109998Smarkm=item B<-noemailDN> 197109998Smarkm 198109998SmarkmThe DN of a certificate can contain the EMAIL field if present in the 199109998Smarkmrequest DN, however it is good policy just having the e-mail set into 200109998Smarkmthe altName extension of the certificate. When this option is set the 201109998SmarkmEMAIL field is removed from the certificate' subject and set only in 202109998Smarkmthe, eventually present, extensions. The B<email_in_dn> keyword can be 203109998Smarkmused in the configuration file to enable this behaviour. 204109998Smarkm 20559191Skris=item B<-batch> 20659191Skris 20759191Skristhis sets the batch mode. In this mode no questions will be asked 20859191Skrisand all certificates will be certified automatically. 20959191Skris 21059191Skris=item B<-extensions section> 21159191Skris 21259191Skristhe section of the configuration file containing certificate extensions 213109998Smarkmto be added when a certificate is issued (defaults to B<x509_extensions> 214109998Smarkmunless the B<-extfile> option is used). If no extension section is 215109998Smarkmpresent then, a V1 certificate is created. If the extension section 216238405Sjkimis present (even if it is empty), then a V3 certificate is created. See the:w 217238405SjkimL<x509v3_config(5)|x509v3_config(5)> manual page for details of the 218238405Sjkimextension section format. 21959191Skris 220109998Smarkm=item B<-extfile file> 221109998Smarkm 222109998Smarkman additional configuration file to read certificate extensions from 223109998Smarkm(using the default section unless the B<-extensions> option is also 224109998Smarkmused). 225109998Smarkm 226111147Snectar=item B<-engine id> 227111147Snectar 228238405Sjkimspecifying an engine (by its unique B<id> string) will cause B<ca> 229111147Snectarto attempt to obtain a functional reference to the specified engine, 230111147Snectarthus initialising it if needed. The engine will then be set as the default 231111147Snectarfor all available algorithms. 232111147Snectar 233160814Ssimon=item B<-subj arg> 234160814Ssimon 235160814Ssimonsupersedes subject name given in the request. 236160814SsimonThe arg must be formatted as I</type0=value0/type1=value1/type2=...>, 237160814Ssimoncharacters may be escaped by \ (backslash), no spaces are skipped. 238160814Ssimon 239160814Ssimon=item B<-utf8> 240160814Ssimon 241160814Ssimonthis option causes field values to be interpreted as UTF8 strings, by 242160814Ssimondefault they are interpreted as ASCII. This means that the field 243160814Ssimonvalues, whether prompted from a terminal or obtained from a 244160814Ssimonconfiguration file, must be valid UTF8 strings. 245160814Ssimon 246160814Ssimon=item B<-multivalue-rdn> 247160814Ssimon 248160814Ssimonthis option causes the -subj argument to be interpretedt with full 249160814Ssimonsupport for multivalued RDNs. Example: 250160814Ssimon 251160814SsimonI</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe> 252160814Ssimon 253160814SsimonIf -multi-rdn is not used then the UID value is I<123456+CN=John Doe>. 254160814Ssimon 25559191Skris=back 25659191Skris 25759191Skris=head1 CRL OPTIONS 25859191Skris 25959191Skris=over 4 26059191Skris 26159191Skris=item B<-gencrl> 26259191Skris 26359191Skristhis option generates a CRL based on information in the index file. 26459191Skris 26559191Skris=item B<-crldays num> 26659191Skris 26759191Skristhe number of days before the next CRL is due. That is the days from 26859191Skrisnow to place in the CRL nextUpdate field. 26959191Skris 27059191Skris=item B<-crlhours num> 27159191Skris 27259191Skristhe number of hours before the next CRL is due. 27359191Skris 27459191Skris=item B<-revoke filename> 27559191Skris 27659191Skrisa filename containing a certificate to revoke. 27759191Skris 278269686Sjkim=item B<-status serial> 279269686Sjkim 280269686Sjkimdisplays the revocation status of the certificate with the specified 281269686Sjkimserial number and exits. 282269686Sjkim 283269686Sjkim=item B<-updatedb> 284269686Sjkim 285269686SjkimUpdates the database index to purge expired certificates. 286269686Sjkim 287109998Smarkm=item B<-crl_reason reason> 288109998Smarkm 289109998Smarkmrevocation reason, where B<reason> is one of: B<unspecified>, B<keyCompromise>, 290109998SmarkmB<CACompromise>, B<affiliationChanged>, B<superseded>, B<cessationOfOperation>, 291109998SmarkmB<certificateHold> or B<removeFromCRL>. The matching of B<reason> is case 292109998Smarkminsensitive. Setting any revocation reason will make the CRL v2. 293109998Smarkm 294109998SmarkmIn practive B<removeFromCRL> is not particularly useful because it is only used 295109998Smarkmin delta CRLs which are not currently implemented. 296109998Smarkm 297109998Smarkm=item B<-crl_hold instruction> 298109998Smarkm 299109998SmarkmThis sets the CRL revocation reason code to B<certificateHold> and the hold 300109998Smarkminstruction to B<instruction> which must be an OID. Although any OID can be 301109998Smarkmused only B<holdInstructionNone> (the use of which is discouraged by RFC2459) 302109998SmarkmB<holdInstructionCallIssuer> or B<holdInstructionReject> will normally be used. 303109998Smarkm 304109998Smarkm=item B<-crl_compromise time> 305109998Smarkm 306109998SmarkmThis sets the revocation reason to B<keyCompromise> and the compromise time to 307109998SmarkmB<time>. B<time> should be in GeneralizedTime format that is B<YYYYMMDDHHMMSSZ>. 308109998Smarkm 309109998Smarkm=item B<-crl_CA_compromise time> 310109998Smarkm 311109998SmarkmThis is the same as B<crl_compromise> except the revocation reason is set to 312109998SmarkmB<CACompromise>. 313109998Smarkm 31459191Skris=item B<-crlexts section> 31559191Skris 31659191Skristhe section of the configuration file containing CRL extensions to 31759191Skrisinclude. If no CRL extension section is present then a V1 CRL is 31859191Skriscreated, if the CRL extension section is present (even if it is 31959191Skrisempty) then a V2 CRL is created. The CRL extensions specified are 32059191SkrisCRL extensions and B<not> CRL entry extensions. It should be noted 321238405Sjkimthat some software (for example Netscape) can't handle V2 CRLs. See 322238405SjkimL<x509v3_config(5)|x509v3_config(5)> manual page for details of the 323238405Sjkimextension section format. 32459191Skris 32559191Skris=back 32659191Skris 32759191Skris=head1 CONFIGURATION FILE OPTIONS 32859191Skris 32989837SkrisThe section of the configuration file containing options for B<ca> 33089837Skrisis found as follows: If the B<-name> command line option is used, 33189837Skristhen it names the section to be used. Otherwise the section to 33289837Skrisbe used must be named in the B<default_ca> option of the B<ca> section 33389837Skrisof the configuration file (or in the default section of the 33489837Skrisconfiguration file). Besides B<default_ca>, the following options are 33589837Skrisread directly from the B<ca> section: 33689837Skris RANDFILE 33789837Skris preserve 33889837Skris msie_hack 33989837SkrisWith the exception of B<RANDFILE>, this is probably a bug and may 34089837Skrischange in future releases. 34189837Skris 34289837SkrisMany of the configuration file options are identical to command line 34359191Skrisoptions. Where the option is present in the configuration file 34459191Skrisand the command line the command line value is used. Where an 34559191Skrisoption is described as mandatory then it must be present in 34659191Skristhe configuration file or the command line equivalent (if 34759191Skrisany) used. 34859191Skris 34959191Skris=over 4 35059191Skris 35159191Skris=item B<oid_file> 35259191Skris 35359191SkrisThis specifies a file containing additional B<OBJECT IDENTIFIERS>. 35459191SkrisEach line of the file should consist of the numerical form of the 35559191Skrisobject identifier followed by white space then the short name followed 35659191Skrisby white space and finally the long name. 35759191Skris 35859191Skris=item B<oid_section> 35959191Skris 36059191SkrisThis specifies a section in the configuration file containing extra 36159191Skrisobject identifiers. Each line should consist of the short name of the 36259191Skrisobject identifier followed by B<=> and the numerical form. The short 36359191Skrisand long names are the same when this option is used. 36459191Skris 36559191Skris=item B<new_certs_dir> 36659191Skris 36759191Skristhe same as the B<-outdir> command line option. It specifies 36859191Skristhe directory where new certificates will be placed. Mandatory. 36959191Skris 37059191Skris=item B<certificate> 37159191Skris 37259191Skristhe same as B<-cert>. It gives the file containing the CA 37359191Skriscertificate. Mandatory. 37459191Skris 37559191Skris=item B<private_key> 37659191Skris 37759191Skrissame as the B<-keyfile> option. The file containing the 37859191SkrisCA private key. Mandatory. 37959191Skris 38059191Skris=item B<RANDFILE> 38159191Skris 38259191Skrisa file used to read and write random number seed information, or 38359191Skrisan EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 38459191Skris 38559191Skris=item B<default_days> 38659191Skris 38759191Skristhe same as the B<-days> option. The number of days to certify 38859191Skrisa certificate for. 38959191Skris 39059191Skris=item B<default_startdate> 39159191Skris 39259191Skristhe same as the B<-startdate> option. The start date to certify 39359191Skrisa certificate for. If not set the current time is used. 39459191Skris 39559191Skris=item B<default_enddate> 39659191Skris 39759191Skristhe same as the B<-enddate> option. Either this option or 39859191SkrisB<default_days> (or the command line equivalents) must be 39959191Skrispresent. 40059191Skris 40159191Skris=item B<default_crl_hours default_crl_days> 40259191Skris 40359191Skristhe same as the B<-crlhours> and the B<-crldays> options. These 40459191Skriswill only be used if neither command line option is present. At 40559191Skrisleast one of these must be present to generate a CRL. 40659191Skris 40759191Skris=item B<default_md> 40859191Skris 40959191Skristhe same as the B<-md> option. The message digest to use. Mandatory. 41059191Skris 41159191Skris=item B<database> 41259191Skris 41359191Skristhe text database file to use. Mandatory. This file must be present 41459191Skristhough initially it will be empty. 41559191Skris 416160814Ssimon=item B<unique_subject> 417160814Ssimon 418160814Ssimonif the value B<yes> is given, the valid certificate entries in the 419160814Ssimondatabase must have unique subjects. if the value B<no> is given, 420160814Ssimonseveral valid certificate entries may have the exact same subject. 421160814SsimonThe default value is B<yes>, to be compatible with older (pre 0.9.8) 422160814Ssimonversions of OpenSSL. However, to make CA certificate roll-over easier, 423160814Ssimonit's recommended to use the value B<no>, especially if combined with 424160814Ssimonthe B<-selfsign> command line option. 425160814Ssimon 426120631Snectar=item B<serial> 42759191Skris 42859191Skrisa text file containing the next serial number to use in hex. Mandatory. 42959191SkrisThis file must be present and contain a valid serial number. 43059191Skris 431160814Ssimon=item B<crlnumber> 432160814Ssimon 433160814Ssimona text file containing the next CRL number to use in hex. The crl number 434160814Ssimonwill be inserted in the CRLs only if this file exists. If this file is 435160814Ssimonpresent, it must contain a valid CRL number. 436160814Ssimon 43759191Skris=item B<x509_extensions> 43859191Skris 43959191Skristhe same as B<-extensions>. 44059191Skris 44159191Skris=item B<crl_extensions> 44259191Skris 44359191Skristhe same as B<-crlexts>. 44459191Skris 44559191Skris=item B<preserve> 44659191Skris 44759191Skristhe same as B<-preserveDN> 44859191Skris 449109998Smarkm=item B<email_in_dn> 450109998Smarkm 451109998Smarkmthe same as B<-noemailDN>. If you want the EMAIL field to be removed 452109998Smarkmfrom the DN of the certificate simply set this to 'no'. If not present 453109998Smarkmthe default is to allow for the EMAIL filed in the certificate's DN. 454109998Smarkm 45559191Skris=item B<msie_hack> 45659191Skris 45759191Skristhe same as B<-msie_hack> 45859191Skris 45959191Skris=item B<policy> 46059191Skris 46159191Skristhe same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section 46259191Skrisfor more information. 46359191Skris 464160814Ssimon=item B<name_opt>, B<cert_opt> 465109998Smarkm 466109998Smarkmthese options allow the format used to display the certificate details 467109998Smarkmwhen asking the user to confirm signing. All the options supported by 468109998Smarkmthe B<x509> utilities B<-nameopt> and B<-certopt> switches can be used 469109998Smarkmhere, except the B<no_signame> and B<no_sigdump> are permanently set 470109998Smarkmand cannot be disabled (this is because the certificate signature cannot 471109998Smarkmbe displayed because the certificate has not been signed at this point). 472109998Smarkm 473120631SnectarFor convenience the values B<ca_default> are accepted by both to produce 474109998Smarkma reasonable output. 475109998Smarkm 476109998SmarkmIf neither option is present the format used in earlier versions of 477109998SmarkmOpenSSL is used. Use of the old format is B<strongly> discouraged because 478109998Smarkmit only displays fields mentioned in the B<policy> section, mishandles 479109998Smarkmmulticharacter string types and does not display extensions. 480109998Smarkm 481109998Smarkm=item B<copy_extensions> 482109998Smarkm 483109998Smarkmdetermines how extensions in certificate requests should be handled. 484109998SmarkmIf set to B<none> or this option is not present then extensions are 485109998Smarkmignored and not copied to the certificate. If set to B<copy> then any 486109998Smarkmextensions present in the request that are not already present are copied 487109998Smarkmto the certificate. If set to B<copyall> then all extensions in the 488109998Smarkmrequest are copied to the certificate: if the extension is already present 489109998Smarkmin the certificate it is deleted first. See the B<WARNINGS> section before 490109998Smarkmusing this option. 491109998Smarkm 492109998SmarkmThe main use of this option is to allow a certificate request to supply 493109998Smarkmvalues for certain extensions such as subjectAltName. 494109998Smarkm 49559191Skris=back 49659191Skris 49759191Skris=head1 POLICY FORMAT 49859191Skris 49959191SkrisThe policy section consists of a set of variables corresponding to 50059191Skriscertificate DN fields. If the value is "match" then the field value 50159191Skrismust match the same field in the CA certificate. If the value is 50259191Skris"supplied" then it must be present. If the value is "optional" then 50359191Skrisit may be present. Any fields not mentioned in the policy section 50459191Skrisare silently deleted, unless the B<-preserveDN> option is set but 50559191Skristhis can be regarded more of a quirk than intended behaviour. 50659191Skris 50759191Skris=head1 SPKAC FORMAT 50859191Skris 50959191SkrisThe input to the B<-spkac> command line option is a Netscape 51059191Skrissigned public key and challenge. This will usually come from 51159191Skristhe B<KEYGEN> tag in an HTML form to create a new private key. 51259191SkrisIt is however possible to create SPKACs using the B<spkac> utility. 51359191Skris 51459191SkrisThe file should contain the variable SPKAC set to the value of 51559191Skristhe SPKAC and also the required DN components as name value pairs. 51659191SkrisIf you need to include the same component twice then it can be 51759191Skrispreceded by a number and a '.'. 51859191Skris 519269686SjkimWhen processing SPKAC format, the output is DER if the B<-out> 520269686Sjkimflag is used, but PEM format if sending to stdout or the B<-outdir> 521269686Sjkimflag is used. 522269686Sjkim 52359191Skris=head1 EXAMPLES 52459191Skris 52559191SkrisNote: these examples assume that the B<ca> directory structure is 52659191Skrisalready set up and the relevant files already exist. This usually 52759191Skrisinvolves creating a CA certificate and private key with B<req>, a 52859191Skrisserial number file and an empty index file and placing them in 52959191Skristhe relevant directories. 53059191Skris 53159191SkrisTo use the sample configuration file below the directories demoCA, 53259191SkrisdemoCA/private and demoCA/newcerts would be created. The CA 53359191Skriscertificate would be copied to demoCA/cacert.pem and its private 53459191Skriskey to demoCA/private/cakey.pem. A file demoCA/serial would be 53559191Skriscreated containing for example "01" and the empty index file 53659191SkrisdemoCA/index.txt. 53759191Skris 53859191Skris 53959191SkrisSign a certificate request: 54059191Skris 54159191Skris openssl ca -in req.pem -out newcert.pem 54259191Skris 54368651SkrisSign a certificate request, using CA extensions: 54468651Skris 54568651Skris openssl ca -in req.pem -extensions v3_ca -out newcert.pem 54668651Skris 54759191SkrisGenerate a CRL 54859191Skris 54959191Skris openssl ca -gencrl -out crl.pem 55059191Skris 55159191SkrisSign several requests: 55259191Skris 55359191Skris openssl ca -infiles req1.pem req2.pem req3.pem 55459191Skris 55559191SkrisCertify a Netscape SPKAC: 55659191Skris 55759191Skris openssl ca -spkac spkac.txt 55859191Skris 55959191SkrisA sample SPKAC file (the SPKAC line has been truncated for clarity): 56059191Skris 56159191Skris SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5 56259191Skris CN=Steve Test 56359191Skris emailAddress=steve@openssl.org 56459191Skris 0.OU=OpenSSL Group 56559191Skris 1.OU=Another Group 56659191Skris 56759191SkrisA sample configuration file with the relevant sections for B<ca>: 56859191Skris 56959191Skris [ ca ] 57059191Skris default_ca = CA_default # The default ca section 57159191Skris 57259191Skris [ CA_default ] 57359191Skris 57459191Skris dir = ./demoCA # top dir 57559191Skris database = $dir/index.txt # index file. 57659191Skris new_certs_dir = $dir/newcerts # new certs dir 57759191Skris 57859191Skris certificate = $dir/cacert.pem # The CA cert 57959191Skris serial = $dir/serial # serial no file 58059191Skris private_key = $dir/private/cakey.pem# CA private key 58159191Skris RANDFILE = $dir/private/.rand # random number file 58259191Skris 58359191Skris default_days = 365 # how long to certify for 58459191Skris default_crl_days= 30 # how long before next CRL 58559191Skris default_md = md5 # md to use 58659191Skris 58759191Skris policy = policy_any # default policy 588109998Smarkm email_in_dn = no # Don't add the email into cert DN 58959191Skris 590160814Ssimon name_opt = ca_default # Subject name display option 591160814Ssimon cert_opt = ca_default # Certificate display option 592109998Smarkm copy_extensions = none # Don't copy extensions from request 593109998Smarkm 59459191Skris [ policy_any ] 59559191Skris countryName = supplied 59659191Skris stateOrProvinceName = optional 59759191Skris organizationName = optional 59859191Skris organizationalUnitName = optional 59959191Skris commonName = supplied 60059191Skris emailAddress = optional 60159191Skris 60259191Skris=head1 FILES 60359191Skris 60459191SkrisNote: the location of all files can change either by compile time options, 60559191Skrisconfiguration file entries, environment variables or command line options. 60659191SkrisThe values below reflect the default values. 60759191Skris 60859191Skris /usr/local/ssl/lib/openssl.cnf - master configuration file 60959191Skris ./demoCA - main CA directory 61059191Skris ./demoCA/cacert.pem - CA certificate 61159191Skris ./demoCA/private/cakey.pem - CA private key 61259191Skris ./demoCA/serial - CA serial number file 61359191Skris ./demoCA/serial.old - CA serial number backup file 61459191Skris ./demoCA/index.txt - CA text database file 61559191Skris ./demoCA/index.txt.old - CA text database backup file 61659191Skris ./demoCA/certs - certificate output file 61759191Skris ./demoCA/.rnd - CA random seed information 61859191Skris 61959191Skris=head1 ENVIRONMENT VARIABLES 62059191Skris 62159191SkrisB<OPENSSL_CONF> reflects the location of master configuration file it can 62259191Skrisbe overridden by the B<-config> command line option. 62359191Skris 62459191Skris=head1 RESTRICTIONS 62559191Skris 62659191SkrisThe text database index file is a critical part of the process and 62759191Skrisif corrupted it can be difficult to fix. It is theoretically possible 62859191Skristo rebuild the index file from all the issued certificates and a current 62959191SkrisCRL: however there is no option to do this. 63059191Skris 631160814SsimonV2 CRL features like delta CRLs are not currently supported. 63259191Skris 63359191SkrisAlthough several requests can be input and handled at once it is only 63459191Skrispossible to include one SPKAC or self signed certificate. 63559191Skris 63659191Skris=head1 BUGS 63759191Skris 63859191SkrisThe use of an in memory text database can cause problems when large 63959191Skrisnumbers of certificates are present because, as the name implies 64059191Skristhe database has to be kept in memory. 64159191Skris 64259191SkrisThe B<ca> command really needs rewriting or the required functionality 64359191Skrisexposed at either a command or interface level so a more friendly utility 64459191Skris(perl script or GUI) can handle things properly. The scripts B<CA.sh> and 64559191SkrisB<CA.pl> help a little but not very much. 64659191Skris 64759191SkrisAny fields in a request that are not present in a policy are silently 648109998Smarkmdeleted. This does not happen if the B<-preserveDN> option is used. To 649109998Smarkmenforce the absence of the EMAIL field within the DN, as suggested by 650109998SmarkmRFCs, regardless the contents of the request' subject the B<-noemailDN> 651109998Smarkmoption can be used. The behaviour should be more friendly and 652109998Smarkmconfigurable. 65359191Skris 65459191SkrisCancelling some commands by refusing to certify a certificate can 65559191Skriscreate an empty file. 65659191Skris 657109998Smarkm=head1 WARNINGS 658109998Smarkm 659109998SmarkmThe B<ca> command is quirky and at times downright unfriendly. 660109998Smarkm 661109998SmarkmThe B<ca> utility was originally meant as an example of how to do things 662109998Smarkmin a CA. It was not supposed to be used as a full blown CA itself: 663109998Smarkmnevertheless some people are using it for this purpose. 664109998Smarkm 665109998SmarkmThe B<ca> command is effectively a single user command: no locking is 666109998Smarkmdone on the various files and attempts to run more than one B<ca> command 667109998Smarkmon the same database can have unpredictable results. 668109998Smarkm 669109998SmarkmThe B<copy_extensions> option should be used with caution. If care is 670109998Smarkmnot taken then it can be a security risk. For example if a certificate 671109998Smarkmrequest contains a basicConstraints extension with CA:TRUE and the 672109998SmarkmB<copy_extensions> value is set to B<copyall> and the user does not spot 673109998Smarkmthis when the certificate is displayed then this will hand the requestor 674109998Smarkma valid CA certificate. 675109998Smarkm 676109998SmarkmThis situation can be avoided by setting B<copy_extensions> to B<copy> 677109998Smarkmand including basicConstraints with CA:FALSE in the configuration file. 678109998SmarkmThen if the request contains a basicConstraints extension it will be 679109998Smarkmignored. 680109998Smarkm 681109998SmarkmIt is advisable to also include values for other extensions such 682109998Smarkmas B<keyUsage> to prevent a request supplying its own values. 683109998Smarkm 684109998SmarkmAdditional restrictions can be placed on the CA certificate itself. 685109998SmarkmFor example if the CA certificate has: 686109998Smarkm 687109998Smarkm basicConstraints = CA:TRUE, pathlen:0 688109998Smarkm 689109998Smarkmthen even if a certificate is issued with CA:TRUE it will not be valid. 690109998Smarkm 69159191Skris=head1 SEE ALSO 69259191Skris 69359191SkrisL<req(1)|req(1)>, L<spkac(1)|spkac(1)>, L<x509(1)|x509(1)>, L<CA.pl(1)|CA.pl(1)>, 694238405SjkimL<config(5)|config(5)>, L<x509v3_config(5)|x509v3_config(5)> 69559191Skris 69659191Skris=cut 697