service_ssl_wrapper.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #ifndef SSL_WRAPPER_INCLUDED
  2. #define SSL_WRAPPER_INCLUDED
  3. /* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License, version 2.0,
  6. as published by the Free Software Foundation.
  7. This program is also distributed with certain software (including
  8. but not limited to OpenSSL) that is licensed under separate terms,
  9. as designated in a particular file or component or in included license
  10. documentation. The authors of MySQL hereby grant you an additional
  11. permission to link the program and your derivative works with the
  12. separately licensed software that they have included with MySQL.
  13. This program 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, version 2.0, for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  20. #include "violite.h"
  21. namespace ssl_wrappe_service
  22. {
  23. int MY_ATTRIBUTE((visibility("default")))
  24. dummy_function_to_ensure_we_are_linked_into_the_server();
  25. } // ssl_wrappe_service
  26. /**
  27. Return version of SSL used in currect connection
  28. @param vio VIO connection descriptor
  29. @param buffer Character buffer in which the version is going to be placed
  30. @param buffer_size Size of the character buffer
  31. */
  32. extern "C"
  33. void ssl_wrapper_version(Vio *vio, char *version, const size_t version_size);
  34. /**
  35. Return cipher used in current connection
  36. @param vio VIO connection descriptor
  37. @param buffer Character buffer in which the cipher name is going to be placed
  38. @param buffer_size Size of the character buffer
  39. */
  40. extern "C"
  41. void ssl_wrapper_cipher(Vio *vio, char *cipher, const size_t cipher_size);
  42. /**
  43. Return cipher list that can be used for SSL
  44. @param vio VIO connection descriptor
  45. @param clipher_list Pointer to an array of c-strings
  46. @param maximun_num_of_elements Size of the pointer array
  47. */
  48. extern "C"
  49. long ssl_wrapper_cipher_list(Vio *vio, const char **clipher_list, const size_t maximun_num_of_elements);
  50. /**
  51. Return the verification depth limit set in SSL
  52. @param vio VIO connection descriptor
  53. @return
  54. -1 default values should be used
  55. >0 verification depth
  56. */
  57. extern "C"
  58. long ssl_wrapper_verify_depth(Vio *vio);
  59. /**
  60. Return the verification mode set in SSL
  61. @param vio VIO connection descriptor
  62. @return
  63. -1 default values should be used
  64. >0 verification mode
  65. */
  66. extern "C"
  67. long ssl_wrapper_verify_mode(Vio *vio);
  68. /**
  69. Return issuer name form peers ssl certificate
  70. @param vio VIO connection descriptor
  71. @param issuer Character buffer in which the issuer name is going to be placed
  72. @param issuer_size Size of character buffer for the issuer name
  73. */
  74. extern "C"
  75. void ssl_wrapper_get_peer_certificate_issuer(Vio *vio, char *issuer, const size_t issuer_size);
  76. /**
  77. Return subject field form peers ssl certificate
  78. @param vio VIO connection descriptor
  79. @param subject Character buffer in which the subject is going to be placed
  80. @param subject_size Size of character buffer for the subject
  81. */
  82. extern "C"
  83. void ssl_wrapper_get_peer_certificate_subject(Vio *vio, char *subject, const size_t subject_size);
  84. /**
  85. Check is peer certificate is present and try to verify it
  86. @param vio VIO connection descriptor
  87. @return
  88. X509_V_OK verification of peer certificate succeeded
  89. -1 verification failed
  90. */
  91. extern "C"
  92. long ssl_wrapper_get_verify_result_and_cert(Vio *vio);
  93. /**
  94. Return the verification depth limit set in SSL context
  95. @param vio_ssl VIO SSL contex descriptor
  96. @return
  97. -1 default values should be used
  98. >0 verification depth
  99. */
  100. extern "C"
  101. long ssl_wrapper_ctx_verify_depth(struct st_VioSSLFd *vio_ssl);
  102. /**
  103. Return the verification mode set in SSL context
  104. @param vio_ssl VIO SSL contex descriptor
  105. @return
  106. -1 default values should be used
  107. >0 verification mode
  108. */
  109. extern "C"
  110. long ssl_wrapper_ctx_verify_mode(struct st_VioSSLFd *vio_ssl);
  111. /**
  112. Return the last day the server certificate is valid
  113. @param vio_ssl VIO SSL contex descriptor
  114. @param no_after Character buffer for to be filed with the date in human readble format
  115. @param no_after_size Size of the character buffer
  116. */
  117. extern "C"
  118. void ssl_wrapper_ctx_server_not_after(struct st_VioSSLFd *vio_ssl, char *no_after, const size_t no_after_size);
  119. /**
  120. Return the first day the server certificate is valid
  121. @param vio_ssl VIO SSL contex descriptor
  122. @param no_before Character buffer for to be filed with the date in human readble format
  123. @param no_before_size Size of the character buffer
  124. */
  125. extern "C"
  126. void ssl_wrapper_ctx_server_not_before(struct st_VioSSLFd *vio_ssl, char *no_before, const size_t no_before_size);
  127. extern "C"
  128. void ssl_wrapper_thread_cleanup();
  129. extern "C"
  130. long ssl_wrapper_sess_accept(struct st_VioSSLFd *vio_ssl);
  131. /**
  132. Cleanup data allocated by SSL on thread stack
  133. */
  134. extern "C"
  135. long ssl_wrapper_sess_accept_good(struct st_VioSSLFd *vio_ssl);
  136. #endif /* SSL_WRAPPER_INCLUDED */