@@ -96,6 +96,7 @@ def initialize
9696 @last_error = nil
9797 @result_exist = false
9898 @local_infile = nil
99+ @ssl_mode = SSL_MODE_PREFERRED
99100 end
100101
101102 # Connect to mysqld.
@@ -112,7 +113,7 @@ def connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, flag=0
112113 warn 'unsupported flag: CLIENT_COMPRESS' if $VERBOSE
113114 flag &= ~CLIENT_COMPRESS
114115 end
115- @protocol = Protocol . new host , port , socket , @connect_timeout , @read_timeout , @write_timeout , @local_infile
116+ @protocol = Protocol . new host , port , socket , @connect_timeout , @read_timeout , @write_timeout , @local_infile , @ssl_mode
116117 @protocol . authenticate user , passwd , db , flag , @charset
117118 @charset ||= @protocol . charset
118119 @host_info = ( host . nil? || host == "localhost" ) ? 'Localhost via UNIX socket' : "#{ host } via TCP/IP"
@@ -145,37 +146,61 @@ def close!
145146 #
146147 # Available options:
147148 # Mysql::INIT_COMMAND, Mysql::OPT_CONNECT_TIMEOUT, Mysql::OPT_READ_TIMEOUT,
148- # Mysql::OPT_WRITE_TIMEOUT, Mysql::SET_CHARSET_NAME
149+ # Mysql::OPT_SSL_MODE, Mysql:: OPT_WRITE_TIMEOUT, Mysql::SET_CHARSET_NAME
149150 # @param [Integer] opt option
150151 # @param [Integer] value option value that is depend on opt
151152 # @return [Mysql] self
152153 def options ( opt , value = nil )
153154 case opt
155+ # when Mysql::DEFAULT_AUTH
156+ # when Mysql::ENABLE_CLEARTEXT_PLUGIN
154157 when Mysql ::INIT_COMMAND
155158 @init_command = value . to_s
159+ # when Mysql::OPT_BIND
160+ # when Mysql::OPT_CAN_HANDLE_EXPIRED_PASSWORDS
156161# when Mysql::OPT_COMPRESS
162+ # when Mysql::OPT_COMPRESSION_ALGORITHMS
163+ # when Mysql::OPT_CONNECT_ATTR_ADD
164+ # when Mysql::OPT_CONNECT_ATTR_DELETE
165+ # when Mysql::OPT_CONNECT_ATTR_RESET
157166 when Mysql ::OPT_CONNECT_TIMEOUT
158167 @connect_timeout = value
159- # when Mysql::GUESS_CONNECTION
160- when Mysql ::OPT_LOCAL_INFILE
161- @local_infile = value ? '' : nil
168+ # when Mysql::OPT_GET_SERVER_PUBLIC_KEY
162169 when Mysql ::OPT_LOAD_DATA_LOCAL_DIR
163170 @local_infile = value
171+ when Mysql ::OPT_LOCAL_INFILE
172+ @local_infile = value ? '' : nil
173+ # when Mysql::OPT_MAX_ALLOWED_PACKET
164174# when Mysql::OPT_NAMED_PIPE
175+ # when Mysql::OPT_NET_BUFFER_LENGTH
176+ # when Mysql::OPT_OPTIONAL_RESULTSET_METADATA
165177# when Mysql::OPT_PROTOCOL
166178 when Mysql ::OPT_READ_TIMEOUT
167179 @read_timeout = value . to_i
168180# when Mysql::OPT_RECONNECT
181+ # when Mysql::OPT_RETRY_COUNT
169182# when Mysql::SET_CLIENT_IP
170- # when Mysql::OPT_SSL_VERIFY_SERVER_CERT
171- # when Mysql::OPT_USE_EMBEDDED_CONNECTION
172- # when Mysql::OPT_USE_REMOTE_CONNECTION
183+ # when Mysql::OPT_SSL_CA
184+ # when Mysql::OPT_SSL_CAPATH
185+ # when Mysql::OPT_SSL_CERT
186+ # when Mysql::OPT_SSL_CIPHER
187+ # when Mysql::OPT_SSL_CRL
188+ # when Mysql::OPT_SSL_CRLPATH
189+ # when Mysql::OPT_SSL_FIPS_MODE
190+ # when Mysql::OPT_SSL_KEY
191+ when Mysql ::OPT_SSL_MODE
192+ @ssl_mode = value
193+ # when Mysql::OPT_TLS_CIPHERSUITES
194+ # when Mysql::OPT_TLS_VERSION
195+ # when Mysql::OPT_USE_RESULT
173196 when Mysql ::OPT_WRITE_TIMEOUT
174197 @write_timeout = value . to_i
198+ # when Mysql::OPT_ZSTD_COMPRESSION_LEVEL
199+ # when Mysql::PLUGIN_DIR
175200# when Mysql::READ_DEFAULT_FILE
176201# when Mysql::READ_DEFAULT_GROUP
177202# when Mysql::REPORT_DATA_TRUNCATION
178- # when Mysql::SECURE_AUTH
203+ # when Mysql::SERVER_PUBLIC_KEY
179204# when Mysql::SET_CHARSET_DIR
180205 when Mysql ::SET_CHARSET_NAME
181206 @charset = Charset . by_name value . to_s
0 commit comments