More X509 verification docs.
[openssl.git] / doc / crypto / X509_STORE_CTX_get_error.pod
1 =pod
2
3 =head1 NAME
4
5 X509_STORE_CTX_get_error, X509_STORE_CTX_set_error, X509_STORE_CTX_get_error_depth, X509_STORE_CTX_get_current_cert, X509_STORE_CTX_get1_chain - get or set certificate verification status information
6
7 =head1 SYNOPSIS
8
9  #include <openssl/x509_vfy.h>
10
11  int    X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
12  void   X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
13  int    X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
14  X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
15
16  STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
17
18 =head1 DESCRIPTION
19
20 These functions are typically called after X509_verify_cert() has indicated
21 an error or in a verification callback to determine the nature of an error.
22
23 X509_STORE_CTX_get_error() returns the error code of B<ctx>, see
24 the B<ERROR CODES> section for a full description of all error codes.
25
26 X509_STORE_CTX_set_error() sets the error code of B<ctx> to B<s>. For example
27 it might be used in a verification callback to set an error based on additional
28 checks.
29
30 X509_STORE_CTX_get_error_depth() returns the B<depth> of the error. This is a
31 non-negative integer representing where in the certificate chain the error
32 occurred. If it is zero it occured in the end entity certificate, one if
33 it is the certificate which signed the end entity certificate and so on.
34
35 X509_STORE_CTX_get_current_cert() returns the certificate in B<ctx> which
36 caused the error or B<NULL> if no certificate is relevant.
37
38 X509_STORE_CTX_get1_chain() returns a complete validate chain if a previous
39 call to X509_verify_cert() is successful. If the call to X509_verify_cert()
40 is B<not> successful the returned chain may be incomplete or invalid. The
41 returned chain persists after the B<ctx> structure is freed, when it is
42 no longer needed it should be free up using:
43
44   sk_X509_pop_free(chain, X509_free);
45
46 =head1 RETURN VALUES
47
48 X509_STORE_CTX_get_error() returns an B<X509_V_OK> or an error code.
49
50 X509_STORE_CTX_get_error_depth() returns a non-negative error depth.
51
52 X509_STORE_CTX_get_current_cert() returns the cerificate which caused the
53 error or B<NULL> if no certificate is relevant to the error.
54
55 =head1 ERROR CODES
56
57 An exhaustive list of the error codes and messages is shown below, this also
58 includes the name of the error code as defined in the header file x509_vfy.h
59 Some of the error codes are defined but never returned: these are described
60 as "unused".
61
62 =over 4
63
64 =item B<0 X509_V_OK: ok>
65
66 the operation was successful.
67
68 =item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
69
70 the issuer certificate could not be found: this occurs if the issuer certificate
71 of an untrusted certificate cannot be found.
72
73 =item B<X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL>
74
75 the CRL of a certificate could not be found.
76
77 =item B<X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
78
79 the certificate signature could not be decrypted. This means that the actual
80 signature value could not be determined rather than it not matching the
81 expected value, this is only meaningful for RSA keys.
82
83 =item B<X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
84
85 the CRL signature could not be decrypted: this means that the actual signature
86 value could not be determined rather than it not matching the expected value.
87 Unused.
88
89 =item B<X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
90
91 the public key in the certificate SubjectPublicKeyInfo could not be read.
92
93 =item B<X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
94
95 the signature of the certificate is invalid.
96
97 =item B<X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
98
99 the signature of the certificate is invalid.
100
101 =item B<X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
102
103 the certificate is not yet valid: the notBefore date is after the current time.
104
105 =item B<X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
106
107 the certificate has expired: that is the notAfter date is before the current time.
108
109 =item B<X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
110
111 the CRL is not yet valid.
112
113 =item B<X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
114
115 the CRL has expired.
116
117 =item B<X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
118
119 the certificate notBefore field contains an invalid time.
120
121 =item B<X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
122
123 the certificate notAfter field contains an invalid time.
124
125 =item B<X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
126
127 the CRL lastUpdate field contains an invalid time.
128
129 =item B<X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
130
131 the CRL nextUpdate field contains an invalid time.
132
133 =item B<X509_V_ERR_OUT_OF_MEM: out of memory>
134
135 an error occurred trying to allocate memory. This should never happen.
136
137 =item B<X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
138
139 the passed certificate is self signed and the same certificate cannot be found
140 in the list of trusted certificates.
141
142 =item B<X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
143
144 the certificate chain could be built up using the untrusted certificates but
145 the root could not be found locally.
146
147 =item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
148
149 the issuer certificate of a locally looked up certificate could not be found.
150 This normally means the list of trusted certificates is not complete.
151
152 =item B<X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
153
154 no signatures could be verified because the chain contains only one certificate
155 and it is not self signed.
156
157 =item B<X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
158
159 the certificate chain length is greater than the supplied maximum depth. Unused.
160
161 =item B<X509_V_ERR_CERT_REVOKED: certificate revoked>
162
163 the certificate has been revoked.
164
165 =item B<X509_V_ERR_INVALID_CA: invalid CA certificate>
166
167 a CA certificate is invalid. Either it is not a CA or its extensions are not
168 consistent with the supplied purpose.
169
170 =item B<X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
171
172 the basicConstraints pathlength parameter has been exceeded.
173
174 =item B<X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
175
176 the supplied certificate cannot be used for the specified purpose.
177
178 =item B<X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
179
180 the root CA is not marked as trusted for the specified purpose.
181
182 =item B<X509_V_ERR_CERT_REJECTED: certificate rejected>
183
184 the root CA is marked to reject the specified purpose.
185
186 =item B<X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch>
187
188 the current candidate issuer certificate was rejected because its subject name
189 did not match the issuer name of the current certificate. This is only set
190 if issuer check debugging is enabled it is used for status notification and
191 is B<not> in itself an error.
192
193 =item B<X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch>
194
195 the current candidate issuer certificate was rejected because its subject key
196 identifier was present and did not match the authority key identifier current
197 certificate. This is only set if issuer check debugging is enabled it is used
198 for status notification and is B<not> in itself an error.
199
200 =item B<X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch>
201
202 the current candidate issuer certificate was rejected because its issuer name
203 and serial number was present and did not match the authority key identifier of
204 the current certificate. This is only set if issuer check debugging is enabled
205 it is used for status notification and is B<not> in itself an error.
206
207 =item B<X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing>
208
209 the current candidate issuer certificate was rejected because its keyUsage
210 extension does not permit certificate signing. This is only set if issuer check
211 debugging is enabled it is used for status notification and is B<not> in itself
212 an error.
213
214 =item B<X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
215
216 an application specific error. This will never be returned unless explicitly
217 set by an application.
218
219 =head1 NOTES
220
221 The above functions should be used instead of directly referencing the fields
222 in the B<X509_VERIFY_CTX> structure.
223
224 In versions of OpenSSL before 1.0 the current certificate returned by
225 X509_STORE_CTX_get_current_cert() was never B<NULL>. Applications should
226 check the return value before printing out any debugging information relating
227 to the current certificate.
228
229 =head1 BUGS
230
231 =head1 SEE ALSO
232
233 L<X509_verify_cert(3)|X509_verify_cert(3)>
234
235 =head1 HISTORY
236
237 TBA
238
239 =cut