diff --git a/src/MySQL.jl b/src/MySQL.jl index 92d62b8..2fc6eff 100644 --- a/src/MySQL.jl +++ b/src/MySQL.jl @@ -128,6 +128,7 @@ function setoptions!(mysql; passphrase::Union{AbstractString, Nothing}=nothing, ssl_verify_server_cert::Union{Bool, Nothing}=nothing, ssl_enforce::Union{Bool, Nothing}=nothing, + ssl_mode::Union{API.mysql_ssl_mode, Nothing}=nothing, default_auth::Union{AbstractString, Nothing}=nothing, connection_handler::Union{AbstractString, Nothing}=nothing, plugin_dir::Union{AbstractString, Nothing}=nothing, @@ -199,6 +200,9 @@ function setoptions!(mysql; if ssl_crlpath !== nothing API.setoption(mysql, API.MYSQL_OPT_SSL_CRLPATH, ssl_crlpath) end + if ssl_mode !== nothing + API.setoption(mysql, API.MYSQL_OPT_SSL_MODE, ssl_mode) + end if passphrase !== nothing API.setoption(mysql, API.MARIADB_OPT_TLS_PASSPHRASE, passphrase) end diff --git a/src/api/consts.jl b/src/api/consts.jl index 0ea04f0..2c43ff6 100644 --- a/src/api/consts.jl +++ b/src/api/consts.jl @@ -140,6 +140,14 @@ end MYSQL_PROTOCOL_MEMORY end +@enum mysql_ssl_mode begin + SSL_MODE_DISABLED + SSL_MODE_PREFERRED + SSL_MODE_REQUIRED + SSL_MODE_VERIFY_CA + SSL_MODE_VERIFY_IDENTITY +end + # Options to be passed to mysql_options API. @enum mysql_option begin MYSQL_OPT_CONNECT_TIMEOUT @@ -212,9 +220,10 @@ end MARIADB_OPT_INTERACTIVE MARIADB_OPT_PROXY_HEADER MARIADB_OPT_IO_WAIT + MYSQL_OPT_SSL_MODE end -const CUINTOPTS = Set([MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_PROTOCOL, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT]) +const CUINTOPTS = Set([MYSQL_OPT_CONNECT_TIMEOUT, MYSQL_OPT_PROTOCOL, MYSQL_OPT_READ_TIMEOUT, MYSQL_OPT_WRITE_TIMEOUT, MYSQL_OPT_SSL_MODE]) const CULONGOPTS = Set([MYSQL_OPT_MAX_ALLOWED_PACKET, MYSQL_OPT_NET_BUFFER_LENGTH]) const BOOLOPTS = Set([MYSQL_ENABLE_CLEARTEXT_PLUGIN, MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, MYSQL_OPT_LOCAL_INFILE, MYSQL_OPT_RECONNECT, MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_SSL_ENFORCE, MYSQL_OPT_SSL_VERIFY_SERVER_CERT]) const STRINGOPTS = Set([MYSQL_DEFAULT_AUTH, MYSQL_OPT_BIND, MYSQL_OPT_SSL_CA, MYSQL_OPT_SSL_CAPATH, MYSQL_OPT_SSL_CERT, MYSQL_OPT_SSL_CIPHER, MYSQL_OPT_SSL_CRL, MYSQL_OPT_SSL_CRLPATH, MYSQL_OPT_SSL_KEY, MYSQL_OPT_TLS_VERSION, MYSQL_PLUGIN_DIR, MYSQL_READ_DEFAULT_FILE, MYSQL_READ_DEFAULT_GROUP, MYSQL_SERVER_PUBLIC_KEY, MYSQL_SET_CHARSET_DIR, MYSQL_SET_CHARSET_NAME, MYSQL_SHARED_MEMORY_BASE_NAME])