Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL_MODE option not behaving correctly with Mysql 5.7 #3913

Closed
ToniIltanen opened this issue Jan 24, 2024 · 3 comments · Fixed by #4027
Closed

SSL_MODE option not behaving correctly with Mysql 5.7 #3913

ToniIltanen opened this issue Jan 24, 2024 · 3 comments · Fixed by #4027

Comments

@ToniIltanen
Copy link

ToniIltanen commented Jan 24, 2024

Setup

Versions

  • Rust: cargo 1.75.0
  • Diesel: 2.1.4
  • Database: Mysql 5.7
  • Operating System: macOS 14.2.1

Feature Flags

  • diesel: mysql

Problem Description

When using ssl_mode=DISABLED in the connection string, the mode is not passed to mysql or is ignored

What are you trying to accomplish?

Connect to Mysql 5.7 database with ssl_mode disabled

What is the expected output?

The connection to succeed

What is the actual output?

SSL connection error: error:0A000102:SSL routines::unsupported protocol

Are you seeing any additional errors?

The following trace is gotten by

 MysqlConnection::establish(&database_url)
        .unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
Error connecting to mysql://root:changeit@127.0.0.1/northwind?ssl_mode=DISABLED

stack backtrace:
   0:        0x104769844 - std::backtrace_rs::backtrace::libunwind::trace::h2966c6fbfac9d426
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x104769844 - std::backtrace_rs::backtrace::trace_unsynchronized::h8a5f4aefe890b7c5
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x104769844 - std::sys_common::backtrace::_print_fmt::h7574dd98fd39c257
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x104769844 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h298c9ab285ff3934
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x10477fff8 - core::fmt::rt::Argument::fmt::hf9661447f7b99899
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:        0x10477fff8 - core::fmt::write::h4e276abdb6d0c2a1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:        0x104767f44 - std::io::Write::write_fmt::hd421848f5f0bf9d0
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:        0x104769680 - std::sys_common::backtrace::_print::h09e653c6686dbd70
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x104769680 - std::sys_common::backtrace::print::hd8bd9ecab1f94b94
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x10476aaa0 - std::panicking::default_hook::{{closure}}::h520eeb743fc98fb4
  10:        0x10476a7e8 - std::panicking::default_hook::ha6550ffe49b63df1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:        0x10476aec8 - std::panicking::rust_panic_with_hook::hddb0e884a202de7c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
  12:        0x10476adc8 - std::panicking::begin_panic_handler::{{closure}}::hd2798398a2fd9077
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  13:        0x104769cac - std::sys_common::backtrace::__rust_end_short_backtrace::h9201cc364dbb8a23
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x10476ab64 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  15:        0x104789728 - core::panicking::panic_fmt::h4d5168028d4c43c7
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  16:        0x1046d2a5c - rusttest::establish_connection::{{closure}}::ha7f7982614e6afcb
                               at /Users/toniiltanen/rusttest/src/lib.rs:13:29
  17:        0x1046d28d4 - core::result::Result<T,E>::unwrap_or_else::h05e8fc6f6a7b10f4
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1430:23
  18:        0x1046d2bb4 - rusttest::establish_connection::hbe5b06d199bedfb3
                               at /Users/toniiltanen/rusttest/src/lib.rs:12:5
  19:        0x1046c3f74 - show_customers::main::h77b66616093fa3b5
                               at /Users/toniiltanen/rusttest/src/bin/show_customers.rs:8:27
  20:        0x1046c49b0 - core::ops::function::FnOnce::call_once::h6b86f42d8ff9f8cc
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  21:        0x1046ccaf8 - std::sys_common::backtrace::__rust_begin_short_backtrace::h85e08f78cd4b0e8a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  22:        0x1046c5aa0 - std::rt::lang_start::{{closure}}::h6fa5e7dccb92eef9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  23:        0x1047654c0 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h1a7c0e059d971da5
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
  24:        0x1047654c0 - std::panicking::try::do_call::h07a34a23e615022b
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  25:        0x1047654c0 - std::panicking::try::h1111644420b4cc09
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  26:        0x1047654c0 - std::panic::catch_unwind::h31a3b9d6e2ef9973
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  27:        0x1047654c0 - std::rt::lang_start_internal::{{closure}}::h63c3452500a36531
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
  28:        0x1047654c0 - std::panicking::try::do_call::h9c5c8a2a0a297bb7
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  29:        0x1047654c0 - std::panicking::try::h424cfcafca1bde97
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  30:        0x1047654c0 - std::panic::catch_unwind::h345d3d448041017f
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  31:        0x1047654c0 - std::rt::lang_start_internal::h5b246d44f1526226
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  32:        0x1046c5a6c - std::rt::lang_start::h4d3609599c289f9d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  33:        0x1046c4314 - _main

In this photo the results are demostrated:

  • the failed use of diesel setup with ssl mode on the connection string env variable
  • the failed use of diesel setup with connection string as the cli parameter
  • the successful use of mysql cli with ssl mode set to disabled
Screenshot 2024-01-24 at 12 07 18

Steps to reproduce

Install Docker image stackupiss/northwind-db:v1, and try to connect.
The connection succeeds with mysql cli with the --ssl-mode parameter, but not with diesel and the parameter on the connection string

Checklist

  • [ x] This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • [ x] This issue can be reproduced without requiring a third party crate
@weiznich
Copy link
Member

weiznich commented Jan 24, 2024

Using the provided issue template is mandatory. Please update your issue description to follow the template. You also want to include details why you came to this conclusion. In addition posting images to issues makes it harder for contributors to see your issue. Try to provide a minimal example or the relevant code as text instead.

@ToniIltanen
Copy link
Author

@weiznich I updated the issue

@ToniIltanen ToniIltanen changed the title SSL_MODE not used correctly SSL_MODE option not behaving correctly Jan 24, 2024
@ToniIltanen ToniIltanen changed the title SSL_MODE option not behaving correctly SSL_MODE option not behaving correctly with Mysql 5.7 Jan 24, 2024
@weiznich weiznich added the mysql label May 14, 2024
@weiznich
Copy link
Member

Might be related to #3996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants