xref: /onnv-gate/usr/src/common/openssl/doc/apps/verify.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948verify - Utility to verify certificates.
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948B<openssl> B<verify>
10*2175Sjp161948[B<-CApath directory>]
11*2175Sjp161948[B<-CAfile file>]
12*2175Sjp161948[B<-purpose purpose>]
13*2175Sjp161948[B<-untrusted file>]
14*2175Sjp161948[B<-help>]
15*2175Sjp161948[B<-issuer_checks>]
16*2175Sjp161948[B<-verbose>]
17*2175Sjp161948[B<->]
18*2175Sjp161948[certificates]
19*2175Sjp161948
20*2175Sjp161948
21*2175Sjp161948=head1 DESCRIPTION
22*2175Sjp161948
23*2175Sjp161948The B<verify> command verifies certificate chains.
24*2175Sjp161948
25*2175Sjp161948=head1 COMMAND OPTIONS
26*2175Sjp161948
27*2175Sjp161948=over 4
28*2175Sjp161948
29*2175Sjp161948=item B<-CApath directory>
30*2175Sjp161948
31*2175Sjp161948A directory of trusted certificates. The certificates should have names
32*2175Sjp161948of the form: hash.0 or have symbolic links to them of this
33*2175Sjp161948form ("hash" is the hashed certificate subject name: see the B<-hash> option
34*2175Sjp161948of the B<x509> utility). Under Unix the B<c_rehash> script will automatically
35*2175Sjp161948create symbolic links to a directory of certificates.
36*2175Sjp161948
37*2175Sjp161948=item B<-CAfile file>
38*2175Sjp161948
39*2175Sjp161948A file of trusted certificates. The file should contain multiple certificates
40*2175Sjp161948in PEM format concatenated together.
41*2175Sjp161948
42*2175Sjp161948=item B<-untrusted file>
43*2175Sjp161948
44*2175Sjp161948A file of untrusted certificates. The file should contain multiple certificates
45*2175Sjp161948
46*2175Sjp161948=item B<-purpose purpose>
47*2175Sjp161948
48*2175Sjp161948the intended use for the certificate. Without this option no chain verification
49*2175Sjp161948will be done. Currently accepted uses are B<sslclient>, B<sslserver>,
50*2175Sjp161948B<nssslserver>, B<smimesign>, B<smimeencrypt>. See the B<VERIFY OPERATION>
51*2175Sjp161948section for more information.
52*2175Sjp161948
53*2175Sjp161948=item B<-help>
54*2175Sjp161948
55*2175Sjp161948prints out a usage message.
56*2175Sjp161948
57*2175Sjp161948=item B<-verbose>
58*2175Sjp161948
59*2175Sjp161948print extra information about the operations being performed.
60*2175Sjp161948
61*2175Sjp161948=item B<-issuer_checks>
62*2175Sjp161948
63*2175Sjp161948print out diagnostics relating to searches for the issuer certificate
64*2175Sjp161948of the current certificate. This shows why each candidate issuer
65*2175Sjp161948certificate was rejected. However the presence of rejection messages
66*2175Sjp161948does not itself imply that anything is wrong: during the normal
67*2175Sjp161948verify process several rejections may take place.
68*2175Sjp161948
69*2175Sjp161948=item B<->
70*2175Sjp161948
71*2175Sjp161948marks the last option. All arguments following this are assumed to be
72*2175Sjp161948certificate files. This is useful if the first certificate filename begins
73*2175Sjp161948with a B<->.
74*2175Sjp161948
75*2175Sjp161948=item B<certificates>
76*2175Sjp161948
77*2175Sjp161948one or more certificates to verify. If no certificate filenames are included
78*2175Sjp161948then an attempt is made to read a certificate from standard input. They should
79*2175Sjp161948all be in PEM format.
80*2175Sjp161948
81*2175Sjp161948
82*2175Sjp161948=back
83*2175Sjp161948
84*2175Sjp161948=head1 VERIFY OPERATION
85*2175Sjp161948
86*2175Sjp161948The B<verify> program uses the same functions as the internal SSL and S/MIME
87*2175Sjp161948verification, therefore this description applies to these verify operations
88*2175Sjp161948too.
89*2175Sjp161948
90*2175Sjp161948There is one crucial difference between the verify operations performed
91*2175Sjp161948by the B<verify> program: wherever possible an attempt is made to continue
92*2175Sjp161948after an error whereas normally the verify operation would halt on the
93*2175Sjp161948first error. This allows all the problems with a certificate chain to be
94*2175Sjp161948determined.
95*2175Sjp161948
96*2175Sjp161948The verify operation consists of a number of separate steps.
97*2175Sjp161948
98*2175Sjp161948Firstly a certificate chain is built up starting from the supplied certificate
99*2175Sjp161948and ending in the root CA. It is an error if the whole chain cannot be built
100*2175Sjp161948up. The chain is built up by looking up the issuers certificate of the current
101*2175Sjp161948certificate. If a certificate is found which is its own issuer it is assumed
102*2175Sjp161948to be the root CA.
103*2175Sjp161948
104*2175Sjp161948The process of 'looking up the issuers certificate' itself involves a number
105*2175Sjp161948of steps. In versions of OpenSSL before 0.9.5a the first certificate whose
106*2175Sjp161948subject name matched the issuer of the current certificate was assumed to be
107*2175Sjp161948the issuers certificate. In OpenSSL 0.9.6 and later all certificates
108*2175Sjp161948whose subject name matches the issuer name of the current certificate are
109*2175Sjp161948subject to further tests. The relevant authority key identifier components
110*2175Sjp161948of the current certificate (if present) must match the subject key identifier
111*2175Sjp161948(if present) and issuer and serial number of the candidate issuer, in addition
112*2175Sjp161948the keyUsage extension of the candidate issuer (if present) must permit
113*2175Sjp161948certificate signing.
114*2175Sjp161948
115*2175Sjp161948The lookup first looks in the list of untrusted certificates and if no match
116*2175Sjp161948is found the remaining lookups are from the trusted certificates. The root CA
117*2175Sjp161948is always looked up in the trusted certificate list: if the certificate to
118*2175Sjp161948verify is a root certificate then an exact match must be found in the trusted
119*2175Sjp161948list.
120*2175Sjp161948
121*2175Sjp161948The second operation is to check every untrusted certificate's extensions for
122*2175Sjp161948consistency with the supplied purpose. If the B<-purpose> option is not included
123*2175Sjp161948then no checks are done. The supplied or "leaf" certificate must have extensions
124*2175Sjp161948compatible with the supplied purpose and all other certificates must also be valid
125*2175Sjp161948CA certificates. The precise extensions required are described in more detail in
126*2175Sjp161948the B<CERTIFICATE EXTENSIONS> section of the B<x509> utility.
127*2175Sjp161948
128*2175Sjp161948The third operation is to check the trust settings on the root CA. The root
129*2175Sjp161948CA should be trusted for the supplied purpose. For compatibility with previous
130*2175Sjp161948versions of SSLeay and OpenSSL a certificate with no trust settings is considered
131*2175Sjp161948to be valid for all purposes.
132*2175Sjp161948
133*2175Sjp161948The final operation is to check the validity of the certificate chain. The validity
134*2175Sjp161948period is checked against the current system time and the notBefore and notAfter
135*2175Sjp161948dates in the certificate. The certificate signatures are also checked at this
136*2175Sjp161948point.
137*2175Sjp161948
138*2175Sjp161948If all operations complete successfully then certificate is considered valid. If
139*2175Sjp161948any operation fails then the certificate is not valid.
140*2175Sjp161948
141*2175Sjp161948=head1 DIAGNOSTICS
142*2175Sjp161948
143*2175Sjp161948When a verify operation fails the output messages can be somewhat cryptic. The
144*2175Sjp161948general form of the error message is:
145*2175Sjp161948
146*2175Sjp161948 server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
147*2175Sjp161948 error 24 at 1 depth lookup:invalid CA certificate
148*2175Sjp161948
149*2175Sjp161948The first line contains the name of the certificate being verified followed by
150*2175Sjp161948the subject name of the certificate. The second line contains the error number
151*2175Sjp161948and the depth. The depth is number of the certificate being verified when a
152*2175Sjp161948problem was detected starting with zero for the certificate being verified itself
153*2175Sjp161948then 1 for the CA that signed the certificate and so on. Finally a text version
154*2175Sjp161948of the error number is presented.
155*2175Sjp161948
156*2175Sjp161948An exhaustive list of the error codes and messages is shown below, this also
157*2175Sjp161948includes the name of the error code as defined in the header file x509_vfy.h
158*2175Sjp161948Some of the error codes are defined but never returned: these are described
159*2175Sjp161948as "unused".
160*2175Sjp161948
161*2175Sjp161948=over 4
162*2175Sjp161948
163*2175Sjp161948=item B<0 X509_V_OK: ok>
164*2175Sjp161948
165*2175Sjp161948the operation was successful.
166*2175Sjp161948
167*2175Sjp161948=item B<2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
168*2175Sjp161948
169*2175Sjp161948the issuer certificate could not be found: this occurs if the issuer certificate
170*2175Sjp161948of an untrusted certificate cannot be found.
171*2175Sjp161948
172*2175Sjp161948=item B<3 X509_V_ERR_UNABLE_TO_GET_CRL unable to get certificate CRL>
173*2175Sjp161948
174*2175Sjp161948the CRL of a certificate could not be found. Unused.
175*2175Sjp161948
176*2175Sjp161948=item B<4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
177*2175Sjp161948
178*2175Sjp161948the certificate signature could not be decrypted. This means that the actual signature value
179*2175Sjp161948could not be determined rather than it not matching the expected value, this is only
180*2175Sjp161948meaningful for RSA keys.
181*2175Sjp161948
182*2175Sjp161948=item B<5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
183*2175Sjp161948
184*2175Sjp161948the CRL signature could not be decrypted: this means that the actual signature value
185*2175Sjp161948could not be determined rather than it not matching the expected value. Unused.
186*2175Sjp161948
187*2175Sjp161948=item B<6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
188*2175Sjp161948
189*2175Sjp161948the public key in the certificate SubjectPublicKeyInfo could not be read.
190*2175Sjp161948
191*2175Sjp161948=item B<7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
192*2175Sjp161948
193*2175Sjp161948the signature of the certificate is invalid.
194*2175Sjp161948
195*2175Sjp161948=item B<8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
196*2175Sjp161948
197*2175Sjp161948the signature of the certificate is invalid. Unused.
198*2175Sjp161948
199*2175Sjp161948=item B<9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
200*2175Sjp161948
201*2175Sjp161948the certificate is not yet valid: the notBefore date is after the current time.
202*2175Sjp161948
203*2175Sjp161948=item B<10 X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
204*2175Sjp161948
205*2175Sjp161948the certificate has expired: that is the notAfter date is before the current time.
206*2175Sjp161948
207*2175Sjp161948=item B<11 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
208*2175Sjp161948
209*2175Sjp161948the CRL is not yet valid. Unused.
210*2175Sjp161948
211*2175Sjp161948=item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
212*2175Sjp161948
213*2175Sjp161948the CRL has expired. Unused.
214*2175Sjp161948
215*2175Sjp161948=item B<13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
216*2175Sjp161948
217*2175Sjp161948the certificate notBefore field contains an invalid time.
218*2175Sjp161948
219*2175Sjp161948=item B<14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
220*2175Sjp161948
221*2175Sjp161948the certificate notAfter field contains an invalid time.
222*2175Sjp161948
223*2175Sjp161948=item B<15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
224*2175Sjp161948
225*2175Sjp161948the CRL lastUpdate field contains an invalid time. Unused.
226*2175Sjp161948
227*2175Sjp161948=item B<16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
228*2175Sjp161948
229*2175Sjp161948the CRL nextUpdate field contains an invalid time. Unused.
230*2175Sjp161948
231*2175Sjp161948=item B<17 X509_V_ERR_OUT_OF_MEM: out of memory>
232*2175Sjp161948
233*2175Sjp161948an error occurred trying to allocate memory. This should never happen.
234*2175Sjp161948
235*2175Sjp161948=item B<18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
236*2175Sjp161948
237*2175Sjp161948the passed certificate is self signed and the same certificate cannot be found in the list of
238*2175Sjp161948trusted certificates.
239*2175Sjp161948
240*2175Sjp161948=item B<19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
241*2175Sjp161948
242*2175Sjp161948the certificate chain could be built up using the untrusted certificates but the root could not
243*2175Sjp161948be found locally.
244*2175Sjp161948
245*2175Sjp161948=item B<20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
246*2175Sjp161948
247*2175Sjp161948the issuer certificate of a locally looked up certificate could not be found. This normally means
248*2175Sjp161948the list of trusted certificates is not complete.
249*2175Sjp161948
250*2175Sjp161948=item B<21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
251*2175Sjp161948
252*2175Sjp161948no signatures could be verified because the chain contains only one certificate and it is not
253*2175Sjp161948self signed.
254*2175Sjp161948
255*2175Sjp161948=item B<22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
256*2175Sjp161948
257*2175Sjp161948the certificate chain length is greater than the supplied maximum depth. Unused.
258*2175Sjp161948
259*2175Sjp161948=item B<23 X509_V_ERR_CERT_REVOKED: certificate revoked>
260*2175Sjp161948
261*2175Sjp161948the certificate has been revoked. Unused.
262*2175Sjp161948
263*2175Sjp161948=item B<24 X509_V_ERR_INVALID_CA: invalid CA certificate>
264*2175Sjp161948
265*2175Sjp161948a CA certificate is invalid. Either it is not a CA or its extensions are not consistent
266*2175Sjp161948with the supplied purpose.
267*2175Sjp161948
268*2175Sjp161948=item B<25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
269*2175Sjp161948
270*2175Sjp161948the basicConstraints pathlength parameter has been exceeded.
271*2175Sjp161948
272*2175Sjp161948=item B<26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
273*2175Sjp161948
274*2175Sjp161948the supplied certificate cannot be used for the specified purpose.
275*2175Sjp161948
276*2175Sjp161948=item B<27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
277*2175Sjp161948
278*2175Sjp161948the root CA is not marked as trusted for the specified purpose.
279*2175Sjp161948
280*2175Sjp161948=item B<28 X509_V_ERR_CERT_REJECTED: certificate rejected>
281*2175Sjp161948
282*2175Sjp161948the root CA is marked to reject the specified purpose.
283*2175Sjp161948
284*2175Sjp161948=item B<29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch>
285*2175Sjp161948
286*2175Sjp161948the current candidate issuer certificate was rejected because its subject name
287*2175Sjp161948did not match the issuer name of the current certificate. Only displayed when
288*2175Sjp161948the B<-issuer_checks> option is set.
289*2175Sjp161948
290*2175Sjp161948=item B<30 X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch>
291*2175Sjp161948
292*2175Sjp161948the current candidate issuer certificate was rejected because its subject key
293*2175Sjp161948identifier was present and did not match the authority key identifier current
294*2175Sjp161948certificate. Only displayed when the B<-issuer_checks> option is set.
295*2175Sjp161948
296*2175Sjp161948=item B<31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch>
297*2175Sjp161948
298*2175Sjp161948the current candidate issuer certificate was rejected because its issuer name
299*2175Sjp161948and serial number was present and did not match the authority key identifier
300*2175Sjp161948of the current certificate. Only displayed when the B<-issuer_checks> option is set.
301*2175Sjp161948
302*2175Sjp161948=item B<32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing>
303*2175Sjp161948
304*2175Sjp161948the current candidate issuer certificate was rejected because its keyUsage extension
305*2175Sjp161948does not permit certificate signing.
306*2175Sjp161948
307*2175Sjp161948=item B<50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
308*2175Sjp161948
309*2175Sjp161948an application specific error. Unused.
310*2175Sjp161948
311*2175Sjp161948=back
312*2175Sjp161948
313*2175Sjp161948=head1 BUGS
314*2175Sjp161948
315*2175Sjp161948Although the issuer checks are a considerably improvement over the old technique they still
316*2175Sjp161948suffer from limitations in the underlying X509_LOOKUP API. One consequence of this is that
317*2175Sjp161948trusted certificates with matching subject name must either appear in a file (as specified by the
318*2175Sjp161948B<-CAfile> option) or a directory (as specified by B<-CApath>. If they occur in both then only
319*2175Sjp161948the certificates in the file will be recognised.
320*2175Sjp161948
321*2175Sjp161948Previous versions of OpenSSL assume certificates with matching subject name are identical and
322*2175Sjp161948mishandled them.
323*2175Sjp161948
324*2175Sjp161948=head1 SEE ALSO
325*2175Sjp161948
326*2175Sjp161948L<x509(1)|x509(1)>
327*2175Sjp161948
328*2175Sjp161948=cut
329