x509_txt.c 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdio.h>
  10. #include <time.h>
  11. #include <errno.h>
  12. #include "internal/cryptlib.h"
  13. #include <openssl/buffer.h>
  14. #include <openssl/evp.h>
  15. #include <openssl/asn1.h>
  16. #include <openssl/x509.h>
  17. #include <openssl/objects.h>
  18. const char *X509_verify_cert_error_string(long n)
  19. {
  20. switch ((int)n) {
  21. case X509_V_OK:
  22. return "ok";
  23. case X509_V_ERR_UNSPECIFIED:
  24. return "unspecified certificate verification error";
  25. case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
  26. return "unable to get issuer certificate";
  27. case X509_V_ERR_UNABLE_TO_GET_CRL:
  28. return "unable to get certificate CRL";
  29. case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
  30. return "unable to decrypt certificate's signature";
  31. case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
  32. return "unable to decrypt CRL's signature";
  33. case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
  34. return "unable to decode issuer public key";
  35. case X509_V_ERR_CERT_SIGNATURE_FAILURE:
  36. return "certificate signature failure";
  37. case X509_V_ERR_CRL_SIGNATURE_FAILURE:
  38. return "CRL signature failure";
  39. case X509_V_ERR_CERT_NOT_YET_VALID:
  40. return "certificate is not yet valid";
  41. case X509_V_ERR_CERT_HAS_EXPIRED:
  42. return "certificate has expired";
  43. case X509_V_ERR_CRL_NOT_YET_VALID:
  44. return "CRL is not yet valid";
  45. case X509_V_ERR_CRL_HAS_EXPIRED:
  46. return "CRL has expired";
  47. case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
  48. return "format error in certificate's notBefore field";
  49. case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
  50. return "format error in certificate's notAfter field";
  51. case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
  52. return "format error in CRL's lastUpdate field";
  53. case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
  54. return "format error in CRL's nextUpdate field";
  55. case X509_V_ERR_OUT_OF_MEM:
  56. return "out of memory";
  57. case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
  58. return "self signed certificate";
  59. case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
  60. return "self signed certificate in certificate chain";
  61. case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
  62. return "unable to get local issuer certificate";
  63. case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
  64. return "unable to verify the first certificate";
  65. case X509_V_ERR_CERT_CHAIN_TOO_LONG:
  66. return "certificate chain too long";
  67. case X509_V_ERR_CERT_REVOKED:
  68. return "certificate revoked";
  69. case X509_V_ERR_INVALID_CA:
  70. return "invalid CA certificate";
  71. case X509_V_ERR_PATH_LENGTH_EXCEEDED:
  72. return "path length constraint exceeded";
  73. case X509_V_ERR_INVALID_PURPOSE:
  74. return "unsupported certificate purpose";
  75. case X509_V_ERR_CERT_UNTRUSTED:
  76. return "certificate not trusted";
  77. case X509_V_ERR_CERT_REJECTED:
  78. return "certificate rejected";
  79. case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:
  80. return "subject issuer mismatch";
  81. case X509_V_ERR_AKID_SKID_MISMATCH:
  82. return "authority and subject key identifier mismatch";
  83. case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:
  84. return "authority and issuer serial number mismatch";
  85. case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:
  86. return "key usage does not include certificate signing";
  87. case X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER:
  88. return "unable to get CRL issuer certificate";
  89. case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:
  90. return "unhandled critical extension";
  91. case X509_V_ERR_KEYUSAGE_NO_CRL_SIGN:
  92. return "key usage does not include CRL signing";
  93. case X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION:
  94. return "unhandled critical CRL extension";
  95. case X509_V_ERR_INVALID_NON_CA:
  96. return "invalid non-CA certificate (has CA markings)";
  97. case X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED:
  98. return "proxy path length constraint exceeded";
  99. case X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE:
  100. return "key usage does not include digital signature";
  101. case X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED:
  102. return
  103. "proxy certificates not allowed, please set the appropriate flag";
  104. case X509_V_ERR_INVALID_EXTENSION:
  105. return "invalid or inconsistent certificate extension";
  106. case X509_V_ERR_INVALID_POLICY_EXTENSION:
  107. return "invalid or inconsistent certificate policy extension";
  108. case X509_V_ERR_NO_EXPLICIT_POLICY:
  109. return "no explicit policy";
  110. case X509_V_ERR_DIFFERENT_CRL_SCOPE:
  111. return "Different CRL scope";
  112. case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE:
  113. return "Unsupported extension feature";
  114. case X509_V_ERR_UNNESTED_RESOURCE:
  115. return "RFC 3779 resource not subset of parent's resources";
  116. case X509_V_ERR_PERMITTED_VIOLATION:
  117. return "permitted subtree violation";
  118. case X509_V_ERR_EXCLUDED_VIOLATION:
  119. return "excluded subtree violation";
  120. case X509_V_ERR_SUBTREE_MINMAX:
  121. return "name constraints minimum and maximum not supported";
  122. case X509_V_ERR_APPLICATION_VERIFICATION:
  123. return "application verification failure";
  124. case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE:
  125. return "unsupported name constraint type";
  126. case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX:
  127. return "unsupported or invalid name constraint syntax";
  128. case X509_V_ERR_UNSUPPORTED_NAME_SYNTAX:
  129. return "unsupported or invalid name syntax";
  130. case X509_V_ERR_CRL_PATH_VALIDATION_ERROR:
  131. return "CRL path validation error";
  132. case X509_V_ERR_PATH_LOOP:
  133. return "Path Loop";
  134. case X509_V_ERR_SUITE_B_INVALID_VERSION:
  135. return "Suite B: certificate version invalid";
  136. case X509_V_ERR_SUITE_B_INVALID_ALGORITHM:
  137. return "Suite B: invalid public key algorithm";
  138. case X509_V_ERR_SUITE_B_INVALID_CURVE:
  139. return "Suite B: invalid ECC curve";
  140. case X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM:
  141. return "Suite B: invalid signature algorithm";
  142. case X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED:
  143. return "Suite B: curve not allowed for this LOS";
  144. case X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256:
  145. return "Suite B: cannot sign P-384 with P-256";
  146. case X509_V_ERR_HOSTNAME_MISMATCH:
  147. return "Hostname mismatch";
  148. case X509_V_ERR_EMAIL_MISMATCH:
  149. return "Email address mismatch";
  150. case X509_V_ERR_IP_ADDRESS_MISMATCH:
  151. return "IP address mismatch";
  152. case X509_V_ERR_DANE_NO_MATCH:
  153. return "No matching DANE TLSA records";
  154. case X509_V_ERR_EE_KEY_TOO_SMALL:
  155. return "EE certificate key too weak";
  156. case X509_V_ERR_CA_KEY_TOO_SMALL:
  157. return "CA certificate key too weak";
  158. case X509_V_ERR_CA_MD_TOO_WEAK:
  159. return "CA signature digest algorithm too weak";
  160. case X509_V_ERR_INVALID_CALL:
  161. return "Invalid certificate verification context";
  162. case X509_V_ERR_STORE_LOOKUP:
  163. return "Issuer certificate lookup error";
  164. case X509_V_ERR_NO_VALID_SCTS:
  165. return "Certificate Transparency required, but no valid SCTs found";
  166. case X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION:
  167. return "proxy subject name violation";
  168. case X509_V_ERR_OCSP_VERIFY_NEEDED:
  169. return "OCSP verification needed";
  170. case X509_V_ERR_OCSP_VERIFY_FAILED:
  171. return "OCSP verification failed";
  172. case X509_V_ERR_OCSP_CERT_UNKNOWN:
  173. return "OCSP unknown cert";
  174. default:
  175. /* Printing an error number into a static buffer is not thread-safe */
  176. return "unknown certificate verification error";
  177. }
  178. }