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

@ -135,14 +135,15 @@ void config_remove_param(CONFIG_CONTEXT* obj, const char* name);
*
* The SSL structure is used by both listeners and servers.
*
* TODO: Rename to something like @c config_construct_ssl
*
* @param obj Configuration context
* @param name Name of object being created (usually server or listener name)
* @param params Parameters to create SSL from
* @param require_cert Whether certificates are required
* @param error_count Pointer to an int which is incremented for each error
* @return New SSL_LISTENER structure or NULL on error
* @param dest Pointer where initialized SSL structure is stored
*
* @return True on success, false on error
*/
SSL_LISTENER *make_ssl_structure(CONFIG_CONTEXT *obj, bool require_cert, int *error_count);
bool config_create_ssl(const char* name, MXS_CONFIG_PARAMETER* params,
bool require_cert, SSL_LISTENER** dest);
/**
* @brief Check if all SSL parameters are defined