Clone of PhatAC @ https://github.com/floaterxk/PhatAC

sslopt-vars.h 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software
  11. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
  12. #ifndef SSLOPT_VARS_INCLUDED
  13. #define SSLOPT_VARS_INCLUDED
  14. #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
  15. #ifndef MYSQL_CLIENT
  16. #error This header is supposed to be used only in the client
  17. #endif
  18. const char *ssl_mode_names_lib[] =
  19. {"DISABLED", "PREFERRED", "REQUIRED", "VERIFY_CA", "VERIFY_IDENTITY",
  20. NullS };
  21. TYPELIB ssl_mode_typelib = {array_elements(ssl_mode_names_lib) - 1, "",
  22. ssl_mode_names_lib, NULL};
  23. static uint opt_ssl_mode = SSL_MODE_PREFERRED;
  24. static char *opt_ssl_ca = 0;
  25. static char *opt_ssl_capath = 0;
  26. static char *opt_ssl_cert = 0;
  27. static char *opt_ssl_cipher = 0;
  28. static char *opt_ssl_key = 0;
  29. static char *opt_ssl_crl = 0;
  30. static char *opt_ssl_crlpath = 0;
  31. static char *opt_tls_version = 0;
  32. static my_bool ssl_mode_set_explicitly= FALSE;
  33. static my_bool opt_use_ssl_arg= TRUE;
  34. static my_bool opt_ssl_verify_server_cert_arg= FALSE;
  35. static void set_client_ssl_options(MYSQL *mysql)
  36. {
  37. /*
  38. Print a warning if explicitly defined combination of --ssl-mode other than
  39. VERIFY_CA or VERIFY_IDENTITY with explicit --ssl-ca or --ssl-capath values.
  40. */
  41. if (ssl_mode_set_explicitly &&
  42. opt_ssl_mode < SSL_MODE_VERIFY_CA &&
  43. (opt_ssl_ca || opt_ssl_capath))
  44. {
  45. printf("WARNING: no verification of server certificate will be done. "
  46. "Use --ssl-mode=VERIFY_CA or VERIFY_IDENTITY.\n");
  47. }
  48. /* Set SSL parameters: key, cert, ca, capath, cipher, clr, clrpath. */
  49. if (opt_ssl_mode >= SSL_MODE_VERIFY_CA)
  50. mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, opt_ssl_ca,
  51. opt_ssl_capath, opt_ssl_cipher);
  52. else
  53. mysql_ssl_set(mysql, opt_ssl_key, opt_ssl_cert, NULL,
  54. NULL, opt_ssl_cipher);
  55. mysql_options(mysql, MYSQL_OPT_SSL_CRL, opt_ssl_crl);
  56. mysql_options(mysql, MYSQL_OPT_SSL_CRLPATH, opt_ssl_crlpath);
  57. mysql_options(mysql, MYSQL_OPT_TLS_VERSION, opt_tls_version);
  58. mysql_options(mysql, MYSQL_OPT_SSL_MODE, &opt_ssl_mode);
  59. }
  60. #define SSL_SET_OPTIONS(mysql) set_client_ssl_options(mysql);
  61. #else
  62. #define SSL_SET_OPTIONS(mysql) do { } while(0)
  63. #endif
  64. #endif /* SSLOPT_VARS_INCLUDED */