blackbeam / rust-mysql-simple

Mysql client library implemented in rust.
Apache License 2.0
665 stars 146 forks source link

Azure Enforce SSL connection #206

Closed 4parsleythelion closed 4 years ago

4parsleythelion commented 4 years ago

I know I'm being stupid with this question, but, I'm at a roadblock. I'm using MySQL on Azure, and I can build the connection string using OptsBuilder, and if I switch "off enforce SSL" from the Portal in Azure I can connect and read information from the database.

But, and this is the stupid part, I just can't get the MySQL client to set the link using SSL? Any ideas?

Thank you,

Ashley

blackbeam commented 4 years ago

Hi.

Well, i can say, that SSL is supported (see here and here) and that the support itself is tested. However there is no way to setup ssl using connection string, you should use OptsBuilder::ssl_opts for this.

Could you please share more details, e.g. debug-print of your OptsBuilder? (⚠️ do not forget to cover sensitive data ⚠️)

4parsleythelion commented 4 years ago

First of all, thank you for your kind response to my question. As requested, please find my OptsBuilder below:

Let mut opts = mysql::OptsBuilder::new(); otps.ip_or_hostname(Some(“myDatabase.mysql.database.azure.com”)) .tcp_port(3306) .db_name(Some(“myDatabase”)) .user(Some(“itsmelook”)) .pass(Some(“somestrongpassword”))

Let pool = mysql::Pool::new(opts).unwrap();

But I can’t figure out how to add the option that will allow the client to negotiate the SSL with the server, thus allowing me to enable the “enforce SSL” on my Azure database portal.

Thank you for your time and effort to answer my question,

Ashley

From: Anatoly I notifications@github.com Sent: Tuesday, February 25, 2020 00:37 To: blackbeam/rust-mysql-simple rust-mysql-simple@noreply.github.com Cc: Ashley S. Buss ashley@elfbuiltsoftware.com; Author author@noreply.github.com Subject: Re: [blackbeam/rust-mysql-simple] Azure Enforce SSL connection (#206)

Hi.

Well, i can say, that SSL is supported (see herehttps://docs.rs/mysql/17.0.0/mysql/struct.OptsBuilder.html#method.ssl_opts and herehttps://docs.rs/mysql/17.0.0/mysql/struct.SslOpts.html) and that the support itself is testedhttps://travis-ci.org/blackbeam/rust-mysql-simple/jobs/653778006#L967. However there is no way to setup ssl using connection string, you should use OptsBuilder::ssl_optshttps://docs.rs/mysql/17.0.0/mysql/struct.OptsBuilder.html#method.ssl_opts for this.

Could you please share more details, e.g. debug-print of your OptsBuilder? (⚠️ do not forget to cover sensitive data ⚠️)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/blackbeam/rust-mysql-simple/issues/206?email_source=notifications&email_token=ANAZXIULH3C7DKDYJCR5MADRETDCXA5CNFSM4K2U4O6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM24KDY#issuecomment-590726415, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAZXITCHEU6QSDMIMOY2JTRETDCXANCNFSM4K2U4O6A.

blackbeam commented 4 years ago

Looks like it's impossible to create Azure subscription from Russia ATM 😔

Have you tried to enable SSL using the default SslOpts?

let mut opts = mysql::OptsBuilder::new();
otps.ip_or_hostname(Some(“myDatabase.mysql.database.azure.com”))
        .tcp_port(3306)
        .db_name(Some(“myDatabase”))
        .user(Some(“itsmelook”))
        .pass(Some(“somestrongpassword”))
        .ssl_opts(mysql::SslOpts::default());  // <- enable SSL with default options

let pool = mysql::Pool::new(opts).unwrap();
4parsleythelion commented 4 years ago

Perfect!

Thank you, thank you.

The addition of the: . ssl_opts(mysql::SslOpts::default)) allows me to select the enforce SSL in the Azure portal.

Take care,

Ashley

From: Anatoly I notifications@github.com Sent: Tuesday, February 25, 2020 21:13 To: blackbeam/rust-mysql-simple rust-mysql-simple@noreply.github.com Cc: Ashley S. Buss ashley@elfbuiltsoftware.com; Author author@noreply.github.com Subject: Re: [blackbeam/rust-mysql-simple] Azure Enforce SSL connection (#206)

Looks like it's impossible to create Azure subscription from Russia ATM 😔

Have you tried to enable SSL using the default SslOpts?

let mut opts = mysql::OptsBuilder::new();

otps.ip_or_hostname(Some(“myDatabase.mysql.database.azure.com”))

    .tcp_port(3306)

    .db_name(Some(“myDatabase”))

    .user(Some(“itsmelook”))

    .pass(Some(“somestrongpassword”))

    .ssl_opts(mysql::SslOpts::default());  // <- enable SSL with default options

let pool = mysql::Pool::new(opts).unwrap();

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/blackbeam/rust-mysql-simple/issues/206?email_source=notifications&email_token=ANAZXIQ464MU5CEWDNYRFZLREXT3NA5CNFSM4K2U4O6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEM6XCYQ#issuecomment-591229282, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAZXIQVKSTKSPQOPFBMA3DREXT3NANCNFSM4K2U4O6A.