Validate SSL parameters via the module-type parameters

The configuration system that modules use allows the SSL parameter
validation to be simplified. It should also provide more consistent error
messages for similar types of errors.

The SSL_LISTENER initialization is now done in one step. There was no good
reason to do it in two separate steps for listeners but in one step for
servers.

The `ssl` parameter now also accepts boolean values. As the parameter
behaves like a boolean and looks like a boolean, it ought to be a
boolean. It still accepts the custom `required` and `disabled` values
simply for backwards compatibility.

Also added the missing freeing functions for the SSL_LISTENER type. This
prevents failed SSL_LISTENER creations from leaking memory.
This commit is contained in:
Markus Mäkelä
2018-07-14 23:02:45 +03:00
parent 1b89c077b1
commit d28b1c9d1d
8 changed files with 267 additions and 295 deletions

View File

@ -778,6 +778,7 @@ static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params
return NULL;
}
SSL_LISTENER *ssl_cfg;
/* Allocate SSL struct for backend connection */
if ((ssl_cfg =
static_cast<SSL_LISTENER*>(MXS_CALLOC(1, sizeof(SSL_LISTENER)))) == NULL)
@ -873,27 +874,6 @@ static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params
if (inst->ssl_enabled)
{
if (service->dbref &&
service->dbref->server &&
service->dbref->server->server_ssl)
{
/* Initialise SSL: exit on error */
if (listener_init_SSL(service->dbref->server->server_ssl) != 0)
{
MXS_ERROR("%s: Unable to initialize SSL with backend server",
service->name);
/* Free SSL struct */
/* Note: SSL struct in server should be freed by server_free() */
blr_free_ssl_data(inst);
server_free(service->dbref->server);
MXS_FREE(service->dbref);
service->dbref = NULL;
sqlite3_close_v2(inst->gtid_maps);
free_instance(inst);
return NULL;
}
}
MXS_INFO("%s: Replicating from master with SSL", service->name);
}
else