10 [B<-CApath directory>]
22 The B<verify> command verifies certificate chains.
24 =head1 COMMAND OPTIONS
28 =item B<-CApath directory>
30 A directory of trusted certificates. The certificates should have names
31 of the form: hash.0 or have symbolic links to them of this
32 form ("hash" is the hashed certificate subject name: see the B<-hash> option
33 of the B<x509> utility). Under Unix the B<c_rehash> script will automatically
34 create symbolic links to a directory of certificates.
38 A file of trusted certificates. The file should contain multiple certificates
39 in PEM format concatenated together.
41 =item B<-untrusted file>
43 A file of untrusted certificates. The file should contain multiple certificates
45 =item B<-purpose purpose>
47 the intended use for the certificate. Without this option no chain verification
48 will be done. Currently accepted uses are B<sslclient>, B<sslserver>,
49 B<nssslserver>, B<smimesign>, B<smimeencrypt>. See the B<VERIFY OPERATION>
50 section for more information.
54 prints out a usage message.
58 print extra information about the operations being performed.
62 marks the last option. All arguments following this are assumed to be
63 certificate files. This is useful if the first certificate filename begins
68 one or more certificates to verify. If no certificate filenames are included
69 then an attempt is made to read a certificate from standard input. They should
75 =head1 VERIFY OPERATION
77 The B<verify> program uses the same functions as the internal SSL and S/MIME
78 verification, therefore this description applies to these verify operations
81 There is one crucial difference between the verify operations performed
82 by the B<verify> program: wherever possible an attempt is made to continue
83 after an error whereas normally the verify operation would halt on the
84 first error. This allows all the problems with a certificate chain to be
87 The verify operation consists of a number of separate steps.
89 Firstly a certificate chain is built up starting from the supplied certificate
90 and ending in the root CA. It is an error if the whole chain cannot be built
91 up. The chain is built up by looking up a certificate whose subject name
92 matches the issuer name of the current certificate. If a certificate is found
93 whose subject and issuer names are identical it is assumed to be the root CA.
94 The lookup first looks in the list of untrusted certificates and if no match
95 is found the remaining lookups are from the trusted certificates. The root CA
96 is always looked up in the trusted certificate list: if the certificate to
97 verify is a root certificate then an exact match must be found in the trusted
100 The second operation is to check every untrusted certificate's extensions for
101 consistency with the supplied purpose. If the B<-purpose> option is not included
102 then no checks are done. The supplied or "leaf" certificate must have extensions
103 compatible with the supplied purpose and all other certificates must also be valid
104 CA certificates. The precise extensions required are described in more detail in
105 the B<CERTIFICATE EXTENSIONS> section of the B<x509> utility.
107 The third operation is to check the trust settings on the root CA. The root
108 CA should be trusted for the supplied purpose. For compatibility with previous
109 versions of SSLeay and OpenSSL a certificate with no trust settings is considered
110 to be valid for all purposes.
112 The final operation is to check the validity of the certificate chain. The validity
113 period is checked against the current system time and the notBefore and notAfter
114 dates in the certificate. The certificate signatures are also checked at this
117 If all operations complete successfully then certificate is considered valid. If
118 any operation fails then the certificate is not valid.
122 When a verify operation fails the output messages can be somewhat cryptic. The
123 general form of the error message is:
125 server.pem: /C=AU/ST=Queensland/O=CryptSoft Pty Ltd/CN=Test CA (1024 bit)
126 error 24 at 1 depth lookup:invalid CA certificate
128 The first line contains the name of the certificate being verified followed by
129 the subject name of the certificate. The second line contains the error number
130 and the depth. The depth is number of the certificate being verified when a
131 problem was detected starting with zero for the certificate being verified itself
132 then 1 for the CA that signed the certificate and so on. Finally a text version
133 of the error number is presented.
135 An exhaustive list of the error codes and messages is shown below, this also
136 includes the name of the error code as defined in the header file x509_vfy.h
137 Some of the error codes are defined but never returned: these are described
142 =item B<0 X509_V_OK: ok>
144 the operation was successful.
146 =item B<2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
148 the issuer certificate could not be found: this occurs if the issuer certificate
149 of an untrusted certificate cannot be found.
151 =item B<3 X509_V_ERR_UNABLE_TO_GET_CRL unable to get certificate CRL>
153 the CRL of a certificate could not be found. Unused.
155 =item B<4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
157 the certificate signature could not be decrypted. This means that the actual signature value
158 could not be determined rather than it not matching the expected value, this is only
159 meaningful for RSA keys.
161 =item B<5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
163 the CRL signature could not be decrypted: this means that the actual signature value
164 could not be determined rather than it not matching the expected value. Unused.
166 =item B<6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
168 the public key in the certificate SubjectPublicKeyInfo could not be read.
170 =item B<7 X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
172 the signature of the certificate is invalid.
174 =item B<8 X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
176 the signature of the certificate is invalid. Unused.
178 =item B<9 X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
180 the certificate is not yet valid: the notBefore date is after the current time.
182 =item B<10 X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
184 the CRL is not yet valid. Unused.
186 =item B<11 X509_V_ERR_CERT_HAS_EXPIRED: Certificate has expired>
188 the certificate has expired: that is the notAfter date is before the current time.
190 =item B<12 X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
192 the CRL has expired. Unused.
194 =item B<13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
196 the certificate notBefore field contains an invalid time.
198 =item B<14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
200 the certificate notAfter field contains an invalid time.
202 =item B<15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
204 the CRL lastUpdate field contains an invalid time. Unused.
206 =item B<16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
208 the CRL nextUpdate field contains an invalid time. Unused.
210 =item B<17 X509_V_ERR_OUT_OF_MEM: out of memory>
212 an error occurred trying to allocate memory. This should never happen.
214 =item B<18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
216 the passed certificate is self signed and the same certificate cannot be found in the list of
217 trusted certificates.
219 =item B<19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
221 the certificate chain could be built up using the untrusted certificates but the root could not
224 =item B<20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
226 the issuer certificate of a locally looked up certificate could not be found. This normally means
227 the list of trusted certificates is not complete.
229 =item B<21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
231 no signatures could be verified because the chain contains only one certificate and it is not
234 =item B<22 X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
236 the certificate chain length is greater than the supplied maximum depth. Unused.
238 =item B<23 X509_V_ERR_CERT_REVOKED: certificate revoked>
240 the certificate has been revoked. Unused.
242 =item B<24 X509_V_ERR_INVALID_CA: invalid CA certificate>
244 a CA certificate is invalid. Either it is not a CA or its extensions are not consistent
245 with the supplied purpose.
247 =item B<25 X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
249 the basicConstraints pathlength parameter has been exceeded.
251 =item B<26 X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
253 the supplied certificate cannot be used for the specified purpose.
255 =item B<27 X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
257 the root CA is not marked as trusted for the specified purpose.
259 =item B<28 X509_V_ERR_CERT_REJECTED: certificate rejected>
261 the root CA is marked to reject the specified purpose.
263 =item B<50 X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
265 an application specific error. Unused.