X509_STORE_CTX_get_error.pod 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. =pod
  2. =head1 NAME
  3. 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, X509_verify_cert_error_string - get or set certificate verification status information
  4. =head1 SYNOPSIS
  5. #include <openssl/x509.h>
  6. #include <openssl/x509_vfy.h>
  7. int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx);
  8. void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx,int s);
  9. int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx);
  10. X509 * X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx);
  11. STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx);
  12. const char *X509_verify_cert_error_string(long n);
  13. =head1 DESCRIPTION
  14. These functions are typically called after X509_verify_cert() has indicated
  15. an error or in a verification callback to determine the nature of an error.
  16. X509_STORE_CTX_get_error() returns the error code of B<ctx>, see
  17. the B<ERROR CODES> section for a full description of all error codes.
  18. X509_STORE_CTX_set_error() sets the error code of B<ctx> to B<s>. For example
  19. it might be used in a verification callback to set an error based on additional
  20. checks.
  21. X509_STORE_CTX_get_error_depth() returns the B<depth> of the error. This is a
  22. non-negative integer representing where in the certificate chain the error
  23. occurred. If it is zero it occured in the end entity certificate, one if
  24. it is the certificate which signed the end entity certificate and so on.
  25. X509_STORE_CTX_get_current_cert() returns the certificate in B<ctx> which
  26. caused the error or B<NULL> if no certificate is relevant.
  27. X509_STORE_CTX_get1_chain() returns a complete validate chain if a previous
  28. call to X509_verify_cert() is successful. If the call to X509_verify_cert()
  29. is B<not> successful the returned chain may be incomplete or invalid. The
  30. returned chain persists after the B<ctx> structure is freed, when it is
  31. no longer needed it should be free up using:
  32. sk_X509_pop_free(chain, X509_free);
  33. X509_verify_cert_error_string() returns a human readable error string for
  34. verification error B<n>.
  35. =head1 RETURN VALUES
  36. X509_STORE_CTX_get_error() returns B<X509_V_OK> or an error code.
  37. X509_STORE_CTX_get_error_depth() returns a non-negative error depth.
  38. X509_STORE_CTX_get_current_cert() returns the cerificate which caused the
  39. error or B<NULL> if no certificate is relevant to the error.
  40. X509_verify_cert_error_string() returns a human readable error string for
  41. verification error B<n>.
  42. =head1 ERROR CODES
  43. A list of error codes and messages is shown below. Some of the
  44. error codes are defined but currently never returned: these are described as
  45. "unused".
  46. =over 4
  47. =item B<X509_V_OK: ok>
  48. the operation was successful.
  49. =item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: unable to get issuer certificate>
  50. the issuer certificate could not be found: this occurs if the issuer certificate
  51. of an untrusted certificate cannot be found.
  52. =item B<X509_V_ERR_UNABLE_TO_GET_CRL: unable to get certificate CRL>
  53. the CRL of a certificate could not be found.
  54. =item B<X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE: unable to decrypt certificate's signature>
  55. the certificate signature could not be decrypted. This means that the actual
  56. signature value could not be determined rather than it not matching the
  57. expected value, this is only meaningful for RSA keys.
  58. =item B<X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE: unable to decrypt CRL's signature>
  59. the CRL signature could not be decrypted: this means that the actual signature
  60. value could not be determined rather than it not matching the expected value.
  61. Unused.
  62. =item B<X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY: unable to decode issuer public key>
  63. the public key in the certificate SubjectPublicKeyInfo could not be read.
  64. =item B<X509_V_ERR_CERT_SIGNATURE_FAILURE: certificate signature failure>
  65. the signature of the certificate is invalid.
  66. =item B<X509_V_ERR_CRL_SIGNATURE_FAILURE: CRL signature failure>
  67. the signature of the certificate is invalid.
  68. =item B<X509_V_ERR_CERT_NOT_YET_VALID: certificate is not yet valid>
  69. the certificate is not yet valid: the notBefore date is after the current time.
  70. =item B<X509_V_ERR_CERT_HAS_EXPIRED: certificate has expired>
  71. the certificate has expired: that is the notAfter date is before the current time.
  72. =item B<X509_V_ERR_CRL_NOT_YET_VALID: CRL is not yet valid>
  73. the CRL is not yet valid.
  74. =item B<X509_V_ERR_CRL_HAS_EXPIRED: CRL has expired>
  75. the CRL has expired.
  76. =item B<X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: format error in certificate's notBefore field>
  77. the certificate notBefore field contains an invalid time.
  78. =item B<X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: format error in certificate's notAfter field>
  79. the certificate notAfter field contains an invalid time.
  80. =item B<X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD: format error in CRL's lastUpdate field>
  81. the CRL lastUpdate field contains an invalid time.
  82. =item B<X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD: format error in CRL's nextUpdate field>
  83. the CRL nextUpdate field contains an invalid time.
  84. =item B<X509_V_ERR_OUT_OF_MEM: out of memory>
  85. an error occurred trying to allocate memory. This should never happen.
  86. =item B<X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT: self signed certificate>
  87. the passed certificate is self signed and the same certificate cannot be found
  88. in the list of trusted certificates.
  89. =item B<X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN: self signed certificate in certificate chain>
  90. the certificate chain could be built up using the untrusted certificates but
  91. the root could not be found locally.
  92. =item B<X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate>
  93. the issuer certificate of a locally looked up certificate could not be found.
  94. This normally means the list of trusted certificates is not complete.
  95. =item B<X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate>
  96. no signatures could be verified because the chain contains only one certificate
  97. and it is not self signed.
  98. =item B<X509_V_ERR_CERT_CHAIN_TOO_LONG: certificate chain too long>
  99. the certificate chain length is greater than the supplied maximum depth. Unused.
  100. =item B<X509_V_ERR_CERT_REVOKED: certificate revoked>
  101. the certificate has been revoked.
  102. =item B<X509_V_ERR_INVALID_CA: invalid CA certificate>
  103. a CA certificate is invalid. Either it is not a CA or its extensions are not
  104. consistent with the supplied purpose.
  105. =item B<X509_V_ERR_PATH_LENGTH_EXCEEDED: path length constraint exceeded>
  106. the basicConstraints pathlength parameter has been exceeded.
  107. =item B<X509_V_ERR_INVALID_PURPOSE: unsupported certificate purpose>
  108. the supplied certificate cannot be used for the specified purpose.
  109. =item B<X509_V_ERR_CERT_UNTRUSTED: certificate not trusted>
  110. the root CA is not marked as trusted for the specified purpose.
  111. =item B<X509_V_ERR_CERT_REJECTED: certificate rejected>
  112. the root CA is marked to reject the specified purpose.
  113. =item B<X509_V_ERR_SUBJECT_ISSUER_MISMATCH: subject issuer mismatch>
  114. the current candidate issuer certificate was rejected because its subject name
  115. did not match the issuer name of the current certificate. This is only set
  116. if issuer check debugging is enabled it is used for status notification and
  117. is B<not> in itself an error.
  118. =item B<X509_V_ERR_AKID_SKID_MISMATCH: authority and subject key identifier mismatch>
  119. the current candidate issuer certificate was rejected because its subject key
  120. identifier was present and did not match the authority key identifier current
  121. certificate. This is only set if issuer check debugging is enabled it is used
  122. for status notification and is B<not> in itself an error.
  123. =item B<X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH: authority and issuer serial number mismatch>
  124. the current candidate issuer certificate was rejected because its issuer name
  125. and serial number was present and did not match the authority key identifier of
  126. the current certificate. This is only set if issuer check debugging is enabled
  127. it is used for status notification and is B<not> in itself an error.
  128. =item B<X509_V_ERR_KEYUSAGE_NO_CERTSIGN:key usage does not include certificate signing>
  129. the current candidate issuer certificate was rejected because its keyUsage
  130. extension does not permit certificate signing. This is only set if issuer check
  131. debugging is enabled it is used for status notification and is B<not> in itself
  132. an error.
  133. =item B<X509_V_ERR_INVALID_EXTENSION: invalid or inconsistent certificate extension>
  134. A certificate extension had an invalid value (for example an incorrect
  135. encoding) or some value inconsistent with other extensions.
  136. =item B<X509_V_ERR_INVALID_POLICY_EXTENSION: invalid or inconsistent certificate policy extension>
  137. A certificate policies extension had an invalid value (for example an incorrect
  138. encoding) or some value inconsistent with other extensions. This error only
  139. occurs if policy processing is enabled.
  140. =item B<X509_V_ERR_NO_EXPLICIT_POLICY: no explicit policy>
  141. The verification flags were set to require and explicit policy but none was
  142. present.
  143. =item B<X509_V_ERR_DIFFERENT_CRL_SCOPE: Different CRL scope>
  144. The only CRLs that could be found did not match the scope of the certificate.
  145. =item B<X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE: Unsupported extension feature>
  146. Some feature of a certificate extension is not supported. Unused.
  147. =item B<X509_V_ERR_PERMITTED_VIOLATION: permitted subtree violation>
  148. A name constraint violation occured in the permitted subtrees.
  149. =item B<X509_V_ERR_EXCLUDED_VIOLATION: excluded subtree violation>
  150. A name constraint violation occured in the excluded subtrees.
  151. =item B<X509_V_ERR_SUBTREE_MINMAX: name constraints minimum and maximum not supported>
  152. A certificate name constraints extension included a minimum or maximum field:
  153. this is not supported.
  154. =item B<X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE: unsupported name constraint type>
  155. An unsupported name constraint type was encountered. OpenSSL currently only
  156. supports directory name, DNS name, email and URI types.
  157. =item B<X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX: unsupported or invalid name constraint syntax>
  158. The format of the name constraint is not recognised: for example an email
  159. address format of a form not mentioned in RFC3280. This could be caused by
  160. a garbage extension or some new feature not currently supported.
  161. =item B<X509_V_ERR_CRL_PATH_VALIDATION_ERROR: CRL path validation error>
  162. An error occured when attempting to verify the CRL path. This error can only
  163. happen if extended CRL checking is enabled.
  164. =item B<X509_V_ERR_APPLICATION_VERIFICATION: application verification failure>
  165. an application specific error. This will never be returned unless explicitly
  166. set by an application.
  167. =head1 NOTES
  168. The above functions should be used instead of directly referencing the fields
  169. in the B<X509_VERIFY_CTX> structure.
  170. In versions of OpenSSL before 1.0 the current certificate returned by
  171. X509_STORE_CTX_get_current_cert() was never B<NULL>. Applications should
  172. check the return value before printing out any debugging information relating
  173. to the current certificate.
  174. If an unrecognised error code is passed to X509_verify_cert_error_string() the
  175. numerical value of the unknown code is returned in a static buffer. This is not
  176. thread safe but will never happen unless an invalid code is passed.
  177. =head1 SEE ALSO
  178. L<X509_verify_cert(3)|X509_verify_cert(3)>
  179. =head1 HISTORY
  180. TBA
  181. =cut