Skip to content

Commit 8125138

Browse files
authored
Travis (#40)
* updates `.travis.yml`. * implements `SslOpts::set_danger_accept_invalid_certs(bool)`.
1 parent 09e0cd0 commit 8125138

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

.travis.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ rust:
55
- nightly
66
- beta
77
- stable
8+
services:
9+
- mysql
810
env:
911
global:
1012
- DATABASE_URL=mysql://root:[email protected]:3306/mysql
1113
before_install:
12-
- sudo bash -c "echo '[mysqld]' >> /usr/share/mysql/my-default.cnf"
13-
- sudo bash -c "echo 'sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES' >> /usr/share/mysql/my-default.cnf"
14-
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('password') where User='root'; FLUSH PRIVILEGES;"
15-
- sudo mysql_upgrade -u root -ppassword
16-
- sudo service mysql restart
14+
- sudo service mysql stop
15+
- mysql_ssl_rsa_setup --verbose --datadir=/tmp/
16+
- mysqld --initialize-insecure --datadir=/tmp/db --log_error=/tmp/error.log --pid-file=/tmp/mysql.pid
17+
- mysqld --sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES --datadir=/tmp/db --socket=/tmp/mysql.sock --max_allowed_packet=32M --ssl --ssl-ca=/tmp/ca.pem --ssl-cert=/tmp/server-cert.pem --ssl-key=/tmp/server-key.pem --log_error=/tmp/error.log --pid-file=/tmp/mysql.pid &
18+
- sleep 20
19+
- cat /tmp/error.log || true
20+
- mysql -h127.0.0.1 -e "use mysql; update user set authentication_string=PASSWORD('password') where User='root'; FLUSH PRIVILEGES;"
1721
before_script:
1822
- export PATH="$PATH:$HOME/.cargo/bin"
1923
- rustup component add rustfmt
2024
script:
2125
- cargo test
2226
- cargo test --features ssl
2327
- cargo fmt -- --check
24-

src/conn/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,8 @@ mod test {
591591
#[cfg(feature = "ssl")]
592592
{
593593
let mut ssl_opts = SslOpts::new();
594-
ssl_opts.set_pkcs12_path(Some(AsRef::<::std::path::Path>::as_ref(
595-
"./test/client.p12",
596-
)));
597-
ssl_opts.set_root_cert_path(Some(AsRef::<::std::path::Path>::as_ref(
598-
"./test/ca-cert.der",
599-
)));
600-
ssl_opts.set_password(Some("pass"));
601594
ssl_opts.set_danger_skip_domain_validation(true);
595+
ssl_opts.set_danger_accept_invalid_certs(true);
602596
builder.ssl_opts(ssl_opts);
603597
}
604598
builder

src/conn/pool/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ impl Pool {
304304
Err(_) => { Ok(()) },
305305
});
306306

307-
// Handle connecting connections.
307+
// Handle connecting connections.
308308
handle!(new {
309309
Ok(Ready(conn)) => {
310310
if inner.closed {

src/io/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ impl Endpoint {
9898
builder.identity(identity);
9999
}
100100
builder.danger_accept_invalid_hostnames(ssl_opts.skip_domain_validation());
101+
builder.danger_accept_invalid_certs(ssl_opts.accept_invalid_certs());
101102
builder.build().map_err(Error::from)
102103
})()
103104
.into_future()

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@
119119
//! ```
120120
121121
#![recursion_limit = "1024"]
122-
#![cfg_attr(feature = "nightly", feature(test, const_fn, extern_crate_item_prelude))]
122+
#![cfg_attr(
123+
feature = "nightly",
124+
feature(test, const_fn, extern_crate_item_prelude)
125+
)]
123126

124127
#[cfg(feature = "nightly")]
125128
extern crate test;

src/opts.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct SslOpts {
3636
password: Option<Cow<'static, str>>,
3737
root_cert_path: Option<Cow<'static, Path>>,
3838
skip_domain_validation: bool,
39+
accept_invalid_certs: bool,
3940
}
4041

4142
impl SslOpts {
@@ -45,6 +46,7 @@ impl SslOpts {
4546
password: None,
4647
root_cert_path: None,
4748
skip_domain_validation: false,
49+
accept_invalid_certs: false,
4850
}
4951
}
5052

@@ -79,6 +81,13 @@ impl SslOpts {
7981
self
8082
}
8183

84+
/// If `true` then client will accept invalid certificate (expired, not trusted, ..)
85+
/// (defaults to `false`).
86+
pub fn set_danger_accept_invalid_certs(&mut self, value: bool) -> &mut Self {
87+
self.accept_invalid_certs = value;
88+
self
89+
}
90+
8291
pub fn pkcs12_path(&self) -> Option<&Path> {
8392
self.pkcs12_path.as_ref().map(|x| x.as_ref())
8493
}
@@ -94,6 +103,10 @@ impl SslOpts {
94103
pub fn skip_domain_validation(&self) -> bool {
95104
self.skip_domain_validation
96105
}
106+
107+
pub fn accept_invalid_certs(&self) -> bool {
108+
self.accept_invalid_certs
109+
}
97110
}
98111

99112
/// Mysql connection options.

0 commit comments

Comments
 (0)