2
0

tls_dump_vf.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * TLS module
  3. *
  4. * Copyright (C) 2006 enum.at
  5. *
  6. * This file is part of Kamailio, a free SIP server.
  7. *
  8. * Kamailio is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * Kamailio is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Exception: permission to copy, modify, propagate, and distribute a work
  23. * formed by combining OpenSSL toolkit software and the code in this file,
  24. * such as linking with software components and libraries released under
  25. * OpenSSL project license.
  26. */
  27. /** log the verification failure reason.
  28. * @file tls_dump_vf.c
  29. * @ingroup: tls
  30. * Module: @ref tls
  31. */
  32. #include "tls_dump_vf.h"
  33. #include <openssl/ssl.h>
  34. #include "../../dprint.h"
  35. #include "tls_mod.h"
  36. #include "tls_cfg.h"
  37. /** log the verification failure reason.
  38. */
  39. void tls_dump_verification_failure(long verification_result)
  40. {
  41. int tls_log;
  42. tls_log = cfg_get(tls, tls_cfg, log);
  43. switch(verification_result) {
  44. case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
  45. LOG(tls_log, "verification failure: unable to get issuer certificate\n");
  46. break;
  47. case X509_V_ERR_UNABLE_TO_GET_CRL:
  48. LOG(tls_log, "verification failure: unable to get certificate CRL\n");
  49. break;
  50. case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE:
  51. LOG(tls_log, "verification failure: unable to decrypt certificate's signature\n");
  52. break;
  53. case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE:
  54. LOG(tls_log, "verification failure: unable to decrypt CRL's signature\n");
  55. break;
  56. case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY:
  57. LOG(tls_log, "verification failure: unable to decode issuer public key\n");
  58. break;
  59. case X509_V_ERR_CERT_SIGNATURE_FAILURE:
  60. LOG(tls_log, "verification failure: certificate signature failure\n");
  61. break;
  62. case X509_V_ERR_CRL_SIGNATURE_FAILURE:
  63. LOG(tls_log, "verification failure: CRL signature failure\n");
  64. break;
  65. case X509_V_ERR_CERT_NOT_YET_VALID:
  66. LOG(tls_log, "verification failure: certificate is not yet valid\n");
  67. break;
  68. case X509_V_ERR_CERT_HAS_EXPIRED:
  69. LOG(tls_log, "verification failure: certificate has expired\n");
  70. break;
  71. case X509_V_ERR_CRL_NOT_YET_VALID:
  72. LOG(tls_log, "verification failure: CRL is not yet valid\n");
  73. break;
  74. case X509_V_ERR_CRL_HAS_EXPIRED:
  75. LOG(tls_log, "verification failure: CRL has expired\n");
  76. break;
  77. case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
  78. LOG(tls_log, "verification failure: format error in certificate's notBefore field\n");
  79. break;
  80. case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD:
  81. LOG(tls_log, "verification failure: format error in certificate's notAfter field\n");
  82. break;
  83. case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD:
  84. LOG(tls_log, "verification failure: format error in CRL's lastUpdate field\n");
  85. break;
  86. case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD:
  87. LOG(tls_log, "verification failure: format error in CRL's nextUpdate field\n");
  88. break;
  89. case X509_V_ERR_OUT_OF_MEM:
  90. LOG(tls_log, "verification failure: out of memory\n");
  91. break;
  92. case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
  93. LOG(tls_log, "verification failure: self signed certificate\n");
  94. break;
  95. case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
  96. LOG(tls_log, "verification failure: self signed certificate in certificate chain\n");
  97. break;
  98. case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
  99. LOG(tls_log, "verification failure: unable to get local issuer certificate\n");
  100. break;
  101. case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
  102. LOG(tls_log, "verification failure: unable to verify the first certificate\n");
  103. break;
  104. case X509_V_ERR_CERT_CHAIN_TOO_LONG:
  105. LOG(tls_log, "verification failure: certificate chain too long\n");
  106. break;
  107. case X509_V_ERR_CERT_REVOKED:
  108. LOG(tls_log, "verification failure: certificate revoked\n");
  109. break;
  110. case X509_V_ERR_INVALID_CA:
  111. LOG(tls_log, "verification failure: invalid CA certificate\n");
  112. break;
  113. case X509_V_ERR_PATH_LENGTH_EXCEEDED:
  114. LOG(tls_log, "verification failure: path length constraint exceeded\n");
  115. break;
  116. case X509_V_ERR_INVALID_PURPOSE:
  117. LOG(tls_log, "verification failure: unsupported certificate purpose\n");
  118. break;
  119. case X509_V_ERR_CERT_UNTRUSTED:
  120. LOG(tls_log, "verification failure: certificate not trusted\n");
  121. break;
  122. case X509_V_ERR_CERT_REJECTED:
  123. LOG(tls_log, "verification failure: certificate rejected\n");
  124. break;
  125. case X509_V_ERR_SUBJECT_ISSUER_MISMATCH:
  126. LOG(tls_log, "verification failure: subject issuer mismatch\n");
  127. break;
  128. case X509_V_ERR_AKID_SKID_MISMATCH:
  129. LOG(tls_log, "verification failure: authority and subject key identifier mismatch\n");
  130. break;
  131. case X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH:
  132. LOG(tls_log, "verification failure: authority and issuer serial number mismatch\n");
  133. break;
  134. case X509_V_ERR_KEYUSAGE_NO_CERTSIGN:
  135. LOG(tls_log, "verification failure: key usage does not include certificate signing\n");
  136. break;
  137. case X509_V_ERR_APPLICATION_VERIFICATION:
  138. LOG(tls_log, "verification failure: application verification failure\n");
  139. break;
  140. }
  141. }
  142. /* vi: set ts=4 sw=4 tw=79:ai:cindent: */