From 333b62a8c216e605e4d5aae595082eb734b1b371 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Mon, 10 Oct 2016 22:21:28 -0700 Subject: [PATCH 1/9] Upgrade phf --- Cargo.toml | 2 +- codegen/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb1ea7bed..bcc8c1214 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ bufstream = "0.1" fallible-iterator = "0.1.3" hex = "0.2" log = "0.3" -phf = "=0.7.15" +phf = "=0.7.17" postgres-protocol = "0.1" bit-vec = { version = "0.4", optional = true } chrono = { version = "0.2.14", optional = true } diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 141bfd6a3..98cec27d5 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" authors = ["Steven Fackler "] [dependencies] -phf_codegen = "=0.7.15" +phf_codegen = "=0.7.17" regex = "0.1" marksman_escape = "0.1" From 839b4914dbc5f196f05defc333a49254496f704b Mon Sep 17 00:00:00 2001 From: p512 Date: Tue, 11 Oct 2016 21:32:51 +0200 Subject: [PATCH 2/9] Add convenience impl IntoConnectParams for String --- src/params.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/params.rs b/src/params.rs index c101ff54d..3c1531d5a 100644 --- a/src/params.rs +++ b/src/params.rs @@ -66,6 +66,12 @@ impl<'a> IntoConnectParams for &'a str { } } +impl IntoConnectParams for String { + fn into_connect_params(self) -> Result> { + self.as_str().into_connect_params() + } +} + impl IntoConnectParams for Url { fn into_connect_params(self) -> Result> { let Url { host, port, user, path: url::Path { mut path, query: options, .. }, .. } = self; From 8bd75c7b71094474c9e3ad39c975f93e43bc07fd Mon Sep 17 00:00:00 2001 From: Kris Date: Wed, 12 Oct 2016 10:49:50 +0100 Subject: [PATCH 3/9] Correct fix for the docs formating --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 02e783be8..e9e6cdad9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -905,6 +905,7 @@ impl Connection { /// # Examples /// /// To connect over TCP: + /// /// ```rust,no_run /// use postgres::{Connection, TlsMode}; /// @@ -913,6 +914,7 @@ impl Connection { /// ``` /// /// To connect over a Unix socket located in `/run/postgres`: + /// /// ```rust,no_run /// use postgres::{Connection, TlsMode}; /// @@ -921,6 +923,7 @@ impl Connection { /// ``` /// /// To connect with a manually constructed `ConnectParams`: + /// /// ```rust,no_run /// use postgres::{Connection, TlsMode}; /// use postgres::params::{UserInfo, ConnectParams, ConnectTarget}; From ae11905c2b96f0282cbde35e1b1529928b79ae73 Mon Sep 17 00:00:00 2001 From: TyanNN Date: Tue, 1 Nov 2016 15:48:03 +0300 Subject: [PATCH 4/9] Update phf version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bcc8c1214..eb9d65a2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ bufstream = "0.1" fallible-iterator = "0.1.3" hex = "0.2" log = "0.3" -phf = "=0.7.17" +phf = "=0.7.18" postgres-protocol = "0.1" bit-vec = { version = "0.4", optional = true } chrono = { version = "0.2.14", optional = true } From 4226b904a4328677982251c7403756436fbc2bab Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 4 Oct 2016 12:22:10 -0700 Subject: [PATCH 5/9] Update benchmark --- benches/bench.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/benches/bench.rs b/benches/bench.rs index db4387a53..2a8428e76 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -1,13 +1,12 @@ +#![feature(test)] extern crate test; extern crate postgres; -use test::Bencher; - -use postgres::{Connection, SslMode}; +use postgres::{Connection, TlsMode}; #[bench] fn bench_naiive_execute(b: &mut test::Bencher) { - let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap(); + let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap(); conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap(); b.iter(|| { @@ -20,7 +19,7 @@ fn bench_naiive_execute(b: &mut test::Bencher) { #[bench] fn bench_execute(b: &mut test::Bencher) { - let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap(); + let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap(); conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap(); b.iter(|| { From 1a281dd8f79c04c9eb46d81618746bb3ee94e336 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 1 Nov 2016 09:05:53 -0700 Subject: [PATCH 6/9] Update codegen codegen version --- codegen/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index 98cec27d5..d9d8af71e 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" authors = ["Steven Fackler "] [dependencies] -phf_codegen = "=0.7.17" +phf_codegen = "=0.7.18" regex = "0.1" marksman_escape = "0.1" From fe0e1ad5a258bab993b043ec377884b291de02d4 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 5 Nov 2016 21:01:26 -0700 Subject: [PATCH 7/9] Update to openssl 0.9 --- Cargo.toml | 5 ++--- src/tls/openssl.rs | 45 ++++++++++++++++++++------------------------- tests/test.rs | 12 ++++++++---- 3 files changed, 30 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index eb9d65a2d..65a3f12a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ path = "tests/test.rs" with-bit-vec = ["bit-vec"] with-chrono = ["chrono"] with-eui48 = ["eui48"] -with-openssl = ["openssl", "openssl-verify"] +with-openssl = ["openssl"] with-rustc-serialize = ["rustc-serialize"] with-security-framework = ["security-framework"] with-serde_json = ["serde_json"] @@ -41,8 +41,7 @@ postgres-protocol = "0.1" bit-vec = { version = "0.4", optional = true } chrono = { version = "0.2.14", optional = true } eui48 = { version = "0.1", optional = true } -openssl-verify = { version = "0.2", optional = true } -openssl = { version = "0.8", optional = true } +openssl = { version = "0.9", optional = true } rustc-serialize = { version = "0.3", optional = true } security-framework = { version = "0.1.2", optional = true } serde_json = { version = ">= 0.6, < 0.9", optional = true } diff --git a/src/tls/openssl.rs b/src/tls/openssl.rs index 406307d0d..f1a8b0e58 100644 --- a/src/tls/openssl.rs +++ b/src/tls/openssl.rs @@ -1,13 +1,11 @@ //! OpenSSL support. extern crate openssl; -extern crate openssl_verify; use std::error::Error; +use std::fmt; use self::openssl::error::ErrorStack; -use self::openssl::ssl::{IntoSsl, SslContext, SslStream, SslMethod, SSL_VERIFY_PEER, - SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3, SSL_OP_NO_COMPRESSION}; -use self::openssl_verify::verify_callback; +use self::openssl::ssl::{SslMethod, SslConnector, SslConnectorBuilder, SslStream}; use tls::{TlsStream, Stream, TlsHandshake}; impl TlsStream for SslStream { @@ -23,35 +21,35 @@ impl TlsStream for SslStream { /// A `TlsHandshake` implementation that uses OpenSSL. /// /// Requires the `with-openssl` feature. -#[derive(Debug)] -pub struct OpenSsl(SslContext); +pub struct OpenSsl(SslConnector); + +impl fmt::Debug for OpenSsl { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("OpenSsl").finish() + } +} impl OpenSsl { - /// Creates a `OpenSsl` with a reasonable default configuration. - /// - /// The configuration is modeled after libcurl's and is subject to change. + /// Creates a `OpenSsl` with `SslConnector`'s default configuration. pub fn new() -> Result { - let mut ctx = try!(SslContext::new(SslMethod::Sslv23)); - try!(ctx.set_default_verify_paths()); - ctx.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION); - try!(ctx.set_cipher_list("ALL!EXPORT!EXPORT40!EXPORT56!aNULL!LOW!RC4@STRENGTH")); - Ok(ctx.into()) + let connector = try!(SslConnectorBuilder::new(SslMethod::tls())).build(); + Ok(OpenSsl(connector)) } - /// Returns a reference to the associated `SslContext`. - pub fn context(&self) -> &SslContext { + /// Returns a reference to the inner `SslConnector`. + pub fn connector(&self) -> &SslConnector { &self.0 } - /// Returns a mutable reference to the associated `SslContext`. - pub fn context_mut(&mut self) -> &mut SslContext { + /// Returns a mutable reference to the inner `SslConnector`. + pub fn connector_mut(&mut self) -> &mut SslConnector { &mut self.0 } } -impl From for OpenSsl { - fn from(ctx: SslContext) -> OpenSsl { - OpenSsl(ctx) +impl From for OpenSsl { + fn from(connector: SslConnector) -> OpenSsl { + OpenSsl(connector) } } @@ -60,10 +58,7 @@ impl TlsHandshake for OpenSsl { domain: &str, stream: Stream) -> Result, Box> { - let domain = domain.to_owned(); - let mut ssl = try!(self.0.into_ssl()); - ssl.set_verify_callback(SSL_VERIFY_PEER, move |p, x| verify_callback(&domain, p, x)); - let stream = try!(SslStream::connect(ssl, stream)); + let stream = try!(self.0.connect(domain, stream)); Ok(Box::new(stream)) } } diff --git a/tests/test.rs b/tests/test.rs index 1f98599c8..2b8e14b76 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -664,10 +664,12 @@ fn test_cancel_query() { #[test] #[cfg(feature = "with-openssl")] fn test_require_ssl_conn() { + use openssl::ssl::{SslMethod, SslConnectorBuilder}; use postgres::tls::openssl::OpenSsl; - let mut negotiator = OpenSsl::new().unwrap(); - negotiator.context_mut().set_CA_file(".travis/server.crt").unwrap(); + let mut builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); + builder.builder_mut().set_ca_file(".travis/server.crt").unwrap(); + let negotiator = OpenSsl::from(builder.build()); let conn = or_panic!(Connection::connect("postgres://postgres@localhost", TlsMode::Require(&negotiator))); or_panic!(conn.execute("SELECT 1::VARCHAR", &[])); @@ -676,10 +678,12 @@ fn test_require_ssl_conn() { #[test] #[cfg(feature = "with-openssl")] fn test_prefer_ssl_conn() { + use openssl::ssl::{SslMethod, SslConnectorBuilder}; use postgres::tls::openssl::OpenSsl; - let mut negotiator = OpenSsl::new().unwrap(); - negotiator.context_mut().set_CA_file(".travis/server.crt").unwrap(); + let mut builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap(); + builder.builder_mut().set_ca_file(".travis/server.crt").unwrap(); + let negotiator = OpenSsl::from(builder.build()); let conn = or_panic!(Connection::connect("postgres://postgres@localhost", TlsMode::Require(&negotiator))); or_panic!(conn.execute("SELECT 1::VARCHAR", &[])); From fdb16ca9ca0b5ea4c153012f13cc6ff2c850702b Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 5 Nov 2016 21:02:40 -0700 Subject: [PATCH 8/9] Update to phf 0.7.19 --- Cargo.toml | 2 +- codegen/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 65a3f12a3..14c9e4d73 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ bufstream = "0.1" fallible-iterator = "0.1.3" hex = "0.2" log = "0.3" -phf = "=0.7.18" +phf = "=0.7.19" postgres-protocol = "0.1" bit-vec = { version = "0.4", optional = true } chrono = { version = "0.2.14", optional = true } diff --git a/codegen/Cargo.toml b/codegen/Cargo.toml index d9d8af71e..1946f3a89 100644 --- a/codegen/Cargo.toml +++ b/codegen/Cargo.toml @@ -4,6 +4,6 @@ version = "0.1.0" authors = ["Steven Fackler "] [dependencies] -phf_codegen = "=0.7.18" +phf_codegen = "=0.7.19" regex = "0.1" marksman_escape = "0.1" From 88aff10e62abecdc04d1fe6925aaabd0214b71f5 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sat, 5 Nov 2016 22:25:24 -0700 Subject: [PATCH 9/9] Release v0.13.0 --- Cargo.toml | 4 ++-- README.md | 4 ++-- src/lib.rs | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 14c9e4d73..1e797e65b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "postgres" -version = "0.12.0" +version = "0.13.0" authors = ["Steven Fackler "] license = "MIT" description = "A native PostgreSQL driver" repository = "https://github.com/sfackler/rust-postgres" -documentation = "https://sfackler.github.io/rust-postgres/doc/v0.12.0/postgres" +documentation = "https://sfackler.github.io/rust-postgres/doc/v0.13.0/postgres" readme = "README.md" keywords = ["database", "postgres", "postgresql", "sql"] include = ["src/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"] diff --git a/README.md b/README.md index 960b7d153..7d8b8e45d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Rust-Postgres A native PostgreSQL driver for Rust. -[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.12.0/postgres) +[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.13.0/postgres) [![Build Status](https://travis-ci.org/sfackler/rust-postgres.png?branch=master)](https://travis-ci.org/sfackler/rust-postgres) [![Latest Version](https://img.shields.io/crates/v/postgres.svg)](https://crates.io/crates/postgres) You can integrate Rust-Postgres into your project through the [releases on crates.io](https://crates.io/crates/postgres): ```toml [dependencies] -postgres = "0.12" +postgres = "0.13" ``` ## Overview diff --git a/src/lib.rs b/src/lib.rs index e9e6cdad9..18162d16b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,13 +62,11 @@ //! # #[cfg(feature = "with-openssl")] //! fn main() { //! let openssl = OpenSsl::new().unwrap(); -//! // Configure the `SslContext` with the `.context()` and `.context_mut()` methods -//! //! let conn = Connection::connect("postgres://postgres@localhost", TlsMode::Require(&openssl)) //! .unwrap(); //! } //! ``` -#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.12.0")] +#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.13.0")] #![warn(missing_docs)] #![allow(unknown_lints, needless_lifetimes, doc_markdown)] // for clippy