summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c15
-rw-r--r--sql-common/mysql_async.c25
2 files changed, 27 insertions, 13 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 858e9ec4b5b..cd9cd9ac09e 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -1054,7 +1054,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd)
EXTENSION_SET_STRING_X(OPTS, X, STR, my_strdup)
-#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
+#if defined(HAVE_TLS) && !defined(EMBEDDED_LIBRARY)
#define SET_SSL_OPTION_X(OPTS, opt_var, arg, dup) \
my_free((OPTS)->opt_var); \
(OPTS)->opt_var= arg ? dup(arg, MYF(MY_WME)) : NULL;
@@ -1071,7 +1071,7 @@ static char *set_ssl_option_unpack_path(const char *arg, myf flags)
#else
#define SET_SSL_OPTION_X(OPTS, opt_var,arg, dup) do { } while(0)
#define EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, dup) do { } while(0)
-#endif /* defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) */
+#endif /* defined(HAVE_TLS) && !defined(EMBEDDED_LIBRARY) */
#define SET_SSL_OPTION(OPTS, opt_var,arg) SET_SSL_OPTION_X(OPTS, opt_var, arg, my_strdup)
#define EXTENSION_SET_SSL_STRING(OPTS, X, STR) EXTENSION_SET_SSL_STRING_X(OPTS, X, STR, my_strdup)
@@ -1666,7 +1666,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
{
my_bool result= 0;
DBUG_ENTER("mysql_ssl_set");
-#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
+#if defined(HAVE_TLS) && !defined(EMBEDDED_LIBRARY)
result= (mysql_options(mysql, MYSQL_OPT_SSL_KEY, key) |
mysql_options(mysql, MYSQL_OPT_SSL_CERT, cert) |
mysql_options(mysql, MYSQL_OPT_SSL_CA, ca) |
@@ -1674,7 +1674,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, cipher) ?
1 : 0);
mysql->options.use_ssl= TRUE;
-#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
+#endif /* HAVE_TLS && !EMBEDDED_LIBRARY */
DBUG_RETURN(result);
}
@@ -1684,7 +1684,7 @@ mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
NB! Errors are not reported until you do mysql_real_connect.
*/
-#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
+#if defined(HAVE_TLS) && !defined(EMBEDDED_LIBRARY)
static void
mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
@@ -1702,8 +1702,10 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused)))
my_free(mysql->options.extension->ssl_crl);
my_free(mysql->options.extension->ssl_crlpath);
}
+#if defined(HAVE_OPENSSL)
if (ssl_fd)
SSL_CTX_free(ssl_fd->ssl_context);
+#endif
my_free(mysql->connector_fd);
mysql->options.ssl_key = 0;
mysql->options.ssl_cert = 0;
@@ -2585,7 +2587,8 @@ static int send_client_reply_packet(MCPVIO_EXT *mpvio,
options->extension ?
options->extension->ssl_crl : NULL,
options->extension ?
- options->extension->ssl_crlpath : NULL)))
+ options->extension->ssl_crlpath : NULL,
+ 0)))
{
set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
ER(CR_SSL_CONNECTION_ERROR), sslGetErrString(ssl_init_error));
diff --git a/sql-common/mysql_async.c b/sql-common/mysql_async.c
index decf48e0e69..f5f8c703cc3 100644
--- a/sql-common/mysql_async.c
+++ b/sql-common/mysql_async.c
@@ -29,6 +29,7 @@
#include "mysql_async.h"
+
#ifdef __WIN__
/*
Windows does not support MSG_DONTWAIT for send()/recv(). So we need to ensure
@@ -214,19 +215,29 @@ my_io_wait_async(struct mysql_async_context *b, enum enum_vio_io_event event,
}
-#ifdef HAVE_OPENSSL
+#ifdef HAVE_TLS
static my_bool
-my_ssl_async_check_result(int res, struct mysql_async_context *b, SSL *ssl)
+my_ssl_async_check_result(int res, struct mysql_async_context *b,
+ MA_TLS_SESSION ssl)
{
int ssl_err;
b->events_to_wait_for= 0;
if (res >= 0)
return 1;
+#if defined(HAVE_OPENSSL)
ssl_err= SSL_get_error(ssl, res);
if (ssl_err == SSL_ERROR_WANT_READ)
b->events_to_wait_for|= MYSQL_WAIT_READ;
else if (ssl_err == SSL_ERROR_WANT_WRITE)
b->events_to_wait_for|= MYSQL_WAIT_WRITE;
+#elif defined(HAVE_GNUTLS)
+ if (res == GNUTLS_E_AGAIN)
+ {
+ b->events_to_wait_for|= gnutls_record_get_direction(ssl) ?
+ MYSQL_WAIT_WRITE : MYSQL_WAIT_READ;
+
+ }
+#endif
else
return 1;
if (b->suspend_resume_hook)
@@ -238,33 +249,33 @@ my_ssl_async_check_result(int res, struct mysql_async_context *b, SSL *ssl)
}
int
-my_ssl_read_async(struct mysql_async_context *b, SSL *ssl,
+my_ssl_read_async(struct mysql_async_context *b, MA_TLS_SESSION ssl,
void *buf, int size)
{
int res;
for (;;)
{
- res= SSL_read(ssl, buf, size);
+ res= ma_tls_read(ssl, buf, size);
if (my_ssl_async_check_result(res, b, ssl))
return res;
}
}
int
-my_ssl_write_async(struct mysql_async_context *b, SSL *ssl,
+my_ssl_write_async(struct mysql_async_context *b, MA_TLS_SESSION ssl,
const void *buf, int size)
{
int res;
for (;;)
{
- res= SSL_write(ssl, buf, size);
+ res= ma_tls_write(ssl, buf, size);
if (my_ssl_async_check_result(res, b, ssl))
return res;
}
}
-#endif /* HAVE_OPENSSL */
+#endif /* HAVE_TLS */
/*
Legacy support of the MariaDB 5.5 version, where timeouts where only in