1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Last commit (fix for CONC-127) was incomplete for unknown reason

This commit is contained in:
Georg Richter
2015-03-18 18:21:47 +01:00
parent f8ebc60f8f
commit 11bcd44fd9
4 changed files with 60 additions and 23 deletions

View File

@@ -1,17 +1,20 @@
/* Copyright (C) 2012 MariaDB Services and Kristian Nielsen /* Copyright (C) 2012 MariaDB Services and Kristian Nielsen
2015 MariaDB Corporation
This program is free software; you can redistribute it and/or modify This library is free software; you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU Library General Public
the Free Software Foundation; version 2 of the License. License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GNU General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this program; if not, write to the Free Software License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA */
/* Common definitions for MariaDB non-blocking client library. */ /* Common definitions for MariaDB non-blocking client library. */

View File

@@ -400,6 +400,7 @@ int my_ssl_connect(SSL *ssl)
{ {
my_bool blocking; my_bool blocking;
MYSQL *mysql; MYSQL *mysql;
int rc;
DBUG_ENTER("my_ssl_connect"); DBUG_ENTER("my_ssl_connect");
@@ -426,6 +427,18 @@ int my_ssl_connect(SSL *ssl)
DBUG_RETURN(1); DBUG_RETURN(1);
} }
rc= SSL_get_verify_result(ssl);
if (rc != X509_V_OK)
{
my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN,
ER(CR_SSL_CONNECTION_ERROR), X509_verify_cert_error_string(rc));
/* restore blocking mode */
if (!blocking)
vio_blocking(mysql->net.vio, FALSE, 0);
DBUG_RETURN(1);
}
vio_reset(mysql->net.vio, VIO_TYPE_SSL, mysql->net.vio->sd, 0, 0); vio_reset(mysql->net.vio, VIO_TYPE_SSL, mysql->net.vio->sd, 0, 0);
mysql->net.vio->ssl= ssl; mysql->net.vio->ssl= ssl;
DBUG_RETURN(0); DBUG_RETURN(0);

View File

@@ -1,19 +1,19 @@
/* /* Copyright (C) 2012 MariaDB Services and Kristian Nielsen
Copyright 2011 Kristian Nielsen and Monty Program Ab 2015 MariaDB Corporation
This file is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Library General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU Library General Public
along with this. If not, see <http://www.gnu.org/licenses/>. License along with this library; if not, write to the Free
*/ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
/* /*
MySQL non-blocking client library functions. MySQL non-blocking client library functions.

View File

@@ -356,7 +356,7 @@ static int test_conc50_2(MYSQL *my)
mysql= mysql_init(NULL); mysql= mysql_init(NULL);
FAIL_IF(!mysql, "Can't allocate memory"); FAIL_IF(!mysql, "Can't allocate memory");
mysql_ssl_set(mysql, NULL, NULL, "@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/dummy.pem", NULL, NULL); mysql_ssl_set(mysql, NULL, NULL, "@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/not-found.pem", NULL, NULL);
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema, mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
port, socketname, 0); port, socketname, 0);
@@ -366,6 +366,26 @@ static int test_conc50_2(MYSQL *my)
return OK; return OK;
} }
static int test_conc127(MYSQL *my)
{
MYSQL *mysql;
if (check_skip_ssl())
return SKIP;
mysql= mysql_init(NULL);
FAIL_IF(!mysql, "Can't allocate memory");
mysql_ssl_set(mysql, NULL, NULL, "@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/dummy.pem", NULL, NULL);
mysql_real_connect(mysql, hostname, ssluser, sslpw, schema,
port, socketname, 0);
FAIL_IF(mysql_errno(mysql) == 0, "Error expected (invalid certificate)");
mysql_close(mysql);
return OK;
}
static int test_conc50_3(MYSQL *my) static int test_conc50_3(MYSQL *my)
{ {
MYSQL *mysql; MYSQL *mysql;
@@ -598,6 +618,7 @@ static int test_conc_102(MYSQL *mysql)
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {
{"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_ssl", test_ssl, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc127", test_conc127, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc50", test_conc50, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_conc50", test_conc50, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc50_1", test_conc50_1, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_conc50_1", test_conc50_1, TEST_CONNECTION_NEW, 0, NULL, NULL},
{"test_conc50_2", test_conc50_2, TEST_CONNECTION_NEW, 0, NULL, NULL}, {"test_conc50_2", test_conc50_2, TEST_CONNECTION_NEW, 0, NULL, NULL},