mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-07-28 06:40:03 +00:00
TLS fixes for C/C 3.4.x
- Always set/unset peer certificate verification flag - Return None (instead of raising an exception) for tls connection properties if TLS is not in use - bumped version number to 1.1.11
This commit is contained in:
@ -225,6 +225,7 @@ typedef struct {
|
||||
#endif
|
||||
PyObject *last_executed_stmt;
|
||||
PyObject *converter;
|
||||
uint8_t tls_in_use;
|
||||
} MrdbConnection;
|
||||
|
||||
typedef struct {
|
||||
|
@ -579,14 +579,18 @@ class Connection(mariadb._mariadb.connection):
|
||||
"""TLS cipher suite if a secure connection is used."""
|
||||
|
||||
self._check_closed()
|
||||
return self._mariadb_get_info(INFO.SSL_CIPHER)
|
||||
if self._tls:
|
||||
return self._mariadb_get_info(INFO.SSL_CIPHER)
|
||||
return None
|
||||
|
||||
@property
|
||||
def tls_version(self):
|
||||
"""TLS protocol version if a secure connection is used."""
|
||||
|
||||
self._check_closed()
|
||||
return self._mariadb_get_info(INFO.TLS_VERSION)
|
||||
if self._tls:
|
||||
return self._mariadb_get_info(INFO.TLS_VERSION)
|
||||
return None
|
||||
|
||||
@property
|
||||
def server_status(self):
|
||||
|
@ -186,6 +186,11 @@ PyMemberDef MrdbConnection_Members[] =
|
||||
offsetof(MrdbConnection, converter),
|
||||
0,
|
||||
"Conversion dictionary"},
|
||||
{"_tls",
|
||||
T_BOOL,
|
||||
offsetof(MrdbConnection, tls_in_use),
|
||||
0,
|
||||
"Indicates if connection uses TLS/SSL"},
|
||||
{NULL} /* always last */
|
||||
};
|
||||
#if MARIADB_PACKAGE_VERSION_ID > 30301
|
||||
@ -435,11 +440,8 @@ MrdbConnection_Initialize(MrdbConnection *self,
|
||||
if (mysql_options(self->mysql, MYSQL_OPT_SSL_CRLPATH, ssl_crlpath))
|
||||
goto end;
|
||||
}
|
||||
if (ssl_verify_cert)
|
||||
{
|
||||
if (mysql_options(self->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (unsigned char *) &ssl_verify_cert))
|
||||
goto end;
|
||||
}
|
||||
if (mysql_options(self->mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, (unsigned char *) &ssl_verify_cert))
|
||||
goto end;
|
||||
if (tls_version)
|
||||
{
|
||||
if (mysql_options(self->mysql, MARIADB_OPT_TLS_VERSION, tls_version))
|
||||
@ -454,6 +456,9 @@ MrdbConnection_Initialize(MrdbConnection *self,
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (mysql_get_ssl_cipher(self->mysql))
|
||||
self->tls_in_use= 1;
|
||||
|
||||
mariadb_get_infov(self->mysql, MARIADB_CONNECTION_HOST, (void *)&self->host);
|
||||
|
||||
has_error= 0;
|
||||
|
Reference in New Issue
Block a user