summaryrefslogtreecommitdiff
path: root/sql-common
diff options
context:
space:
mode:
Diffstat (limited to 'sql-common')
-rw-r--r--sql-common/client.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 9972ca741f2..3247fd8e339 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -2020,6 +2020,34 @@ error:
#endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */
+/**
+ Checks if any SSL option is set for libmysqld embedded server.
+
+ @param mysql the connection handle
+ @retval 0 success
+ @retval 1 failure
+*/
+#ifdef EMBEDDED_LIBRARY
+int embedded_ssl_check(MYSQL *mysql)
+{
+ if (mysql->options.ssl_key || mysql->options.ssl_cert ||
+ mysql->options.ssl_ca || mysql->options.ssl_capath ||
+ mysql->options.ssl_cipher ||
+ mysql->options.client_flag & CLIENT_SSL_VERIFY_SERVER_CERT ||
+ (mysql->options.extension &&
+ mysql->options.extension->ssl_mode == SSL_MODE_REQUIRED))
+ {
+ set_mysql_extended_error(mysql, CR_SSL_CONNECTION_ERROR, unknown_sqlstate,
+ ER(CR_SSL_CONNECTION_ERROR),
+ "Embedded server libmysqld library doesn't support "
+ "SSL connections");
+ return 1;
+ }
+ return 0;
+}
+#endif
+
+
/*
Note that the mysql argument must be initialized with mysql_init()
before calling mysql_real_connect !
@@ -3592,6 +3620,11 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
mysql->client_flag= client_flag;
+#ifdef EMBEDDED_LIBRARY
+ if (embedded_ssl_check(mysql))
+ goto error;
+#endif
+
/*
Part 2: invoke the plugin to send the authentication data to the server
*/
@@ -4271,10 +4304,14 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
mysql->reconnect= *(my_bool *) arg;
break;
case MYSQL_OPT_SSL_VERIFY_SERVER_CERT:
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if (*(my_bool*) arg)
mysql->options.client_flag|= CLIENT_SSL_VERIFY_SERVER_CERT;
else
mysql->options.client_flag&= ~CLIENT_SSL_VERIFY_SERVER_CERT;
+#elif defined(EMBEDDED_LIBRARY)
+ DBUG_RETURN(1);
+#endif
break;
case MYSQL_PLUGIN_DIR:
EXTENSION_SET_STRING(&mysql->options, plugin_dir, arg);
@@ -4288,11 +4325,15 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg)
(*(my_bool*) arg) ? TRUE : FALSE;
break;
case MYSQL_OPT_SSL_MODE:
+#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
if (*(uint *) arg == SSL_MODE_REQUIRED)
{
ENSURE_EXTENSIONS_PRESENT(&mysql->options);
mysql->options.extension->ssl_mode= SSL_MODE_REQUIRED;
}
+#elif defined(EMBEDDED_LIBRARY)
+ DBUG_RETURN(1);
+#endif
break;
default:
DBUG_RETURN(1);