Skip to content

Commit 69477cd

Browse files
committed
Merge branch 'release-v0.13.0' into release
2 parents 6529336 + 88aff10 commit 69477cd

File tree

8 files changed

+50
-46
lines changed

8 files changed

+50
-46
lines changed

Cargo.toml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "postgres"
3-
version = "0.12.0"
3+
version = "0.13.0"
44
authors = ["Steven Fackler <[email protected]>"]
55
license = "MIT"
66
description = "A native PostgreSQL driver"
77
repository = "https://github.com/sfackler/rust-postgres"
8-
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.12.0/postgres"
8+
documentation = "https://sfackler.github.io/rust-postgres/doc/v0.13.0/postgres"
99
readme = "README.md"
1010
keywords = ["database", "postgres", "postgresql", "sql"]
1111
include = ["src/*", "Cargo.toml", "LICENSE", "README.md", "THIRD_PARTY"]
@@ -24,7 +24,7 @@ path = "tests/test.rs"
2424
with-bit-vec = ["bit-vec"]
2525
with-chrono = ["chrono"]
2626
with-eui48 = ["eui48"]
27-
with-openssl = ["openssl", "openssl-verify"]
27+
with-openssl = ["openssl"]
2828
with-rustc-serialize = ["rustc-serialize"]
2929
with-security-framework = ["security-framework"]
3030
with-serde_json = ["serde_json"]
@@ -36,13 +36,12 @@ bufstream = "0.1"
3636
fallible-iterator = "0.1.3"
3737
hex = "0.2"
3838
log = "0.3"
39-
phf = "=0.7.15"
39+
phf = "=0.7.19"
4040
postgres-protocol = "0.1"
4141
bit-vec = { version = "0.4", optional = true }
4242
chrono = { version = "0.2.14", optional = true }
4343
eui48 = { version = "0.1", optional = true }
44-
openssl-verify = { version = "0.2", optional = true }
45-
openssl = { version = "0.8", optional = true }
44+
openssl = { version = "0.9", optional = true }
4645
rustc-serialize = { version = "0.3", optional = true }
4746
security-framework = { version = "0.1.2", optional = true }
4847
serde_json = { version = ">= 0.6, < 0.9", optional = true }

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Rust-Postgres
22
A native PostgreSQL driver for Rust.
33

4-
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.12.0/postgres)
4+
[Documentation](https://sfackler.github.io/rust-postgres/doc/v0.13.0/postgres)
55

66
[![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)
77

88
You can integrate Rust-Postgres into your project through the [releases on crates.io](https://crates.io/crates/postgres):
99
```toml
1010
[dependencies]
11-
postgres = "0.12"
11+
postgres = "0.13"
1212
```
1313

1414
## Overview

benches/bench.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1+
#![feature(test)]
12
extern crate test;
23
extern crate postgres;
34

4-
use test::Bencher;
5-
6-
use postgres::{Connection, SslMode};
5+
use postgres::{Connection, TlsMode};
76

87
#[bench]
98
fn bench_naiive_execute(b: &mut test::Bencher) {
10-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
9+
let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
1110
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
1211

1312
b.iter(|| {
@@ -20,7 +19,7 @@ fn bench_naiive_execute(b: &mut test::Bencher) {
2019

2120
#[bench]
2221
fn bench_execute(b: &mut test::Bencher) {
23-
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
22+
let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
2423
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
2524

2625
b.iter(|| {

codegen/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ version = "0.1.0"
44
authors = ["Steven Fackler <[email protected]>"]
55

66
[dependencies]
7-
phf_codegen = "=0.7.15"
7+
phf_codegen = "=0.7.19"
88
regex = "0.1"
99
marksman_escape = "0.1"

src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@
6262
//! # #[cfg(feature = "with-openssl")]
6363
//! fn main() {
6464
//! let openssl = OpenSsl::new().unwrap();
65-
//! // Configure the `SslContext` with the `.context()` and `.context_mut()` methods
66-
//!
6765
//! let conn = Connection::connect("postgres://postgres@localhost", TlsMode::Require(&openssl))
6866
//! .unwrap();
6967
//! }
7068
//! ```
71-
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.12.0")]
69+
#![doc(html_root_url="https://sfackler.github.io/rust-postgres/doc/v0.13.0")]
7270
#![warn(missing_docs)]
7371
#![allow(unknown_lints, needless_lifetimes, doc_markdown)] // for clippy
7472

@@ -905,6 +903,7 @@ impl Connection {
905903
/// # Examples
906904
///
907905
/// To connect over TCP:
906+
///
908907
/// ```rust,no_run
909908
/// use postgres::{Connection, TlsMode};
910909
///
@@ -913,6 +912,7 @@ impl Connection {
913912
/// ```
914913
///
915914
/// To connect over a Unix socket located in `/run/postgres`:
915+
///
916916
/// ```rust,no_run
917917
/// use postgres::{Connection, TlsMode};
918918
///
@@ -921,6 +921,7 @@ impl Connection {
921921
/// ```
922922
///
923923
/// To connect with a manually constructed `ConnectParams`:
924+
///
924925
/// ```rust,no_run
925926
/// use postgres::{Connection, TlsMode};
926927
/// use postgres::params::{UserInfo, ConnectParams, ConnectTarget};

src/params.rs

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ impl<'a> IntoConnectParams for &'a str {
6666
}
6767
}
6868

69+
impl IntoConnectParams for String {
70+
fn into_connect_params(self) -> Result<ConnectParams, Box<Error + Sync + Send>> {
71+
self.as_str().into_connect_params()
72+
}
73+
}
74+
6975
impl IntoConnectParams for Url {
7076
fn into_connect_params(self) -> Result<ConnectParams, Box<Error + Sync + Send>> {
7177
let Url { host, port, user, path: url::Path { mut path, query: options, .. }, .. } = self;

src/tls/openssl.rs

+20-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
//! OpenSSL support.
22
extern crate openssl;
3-
extern crate openssl_verify;
43

54
use std::error::Error;
5+
use std::fmt;
66

77
use self::openssl::error::ErrorStack;
8-
use self::openssl::ssl::{IntoSsl, SslContext, SslStream, SslMethod, SSL_VERIFY_PEER,
9-
SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3, SSL_OP_NO_COMPRESSION};
10-
use self::openssl_verify::verify_callback;
8+
use self::openssl::ssl::{SslMethod, SslConnector, SslConnectorBuilder, SslStream};
119
use tls::{TlsStream, Stream, TlsHandshake};
1210

1311
impl TlsStream for SslStream<Stream> {
@@ -23,35 +21,35 @@ impl TlsStream for SslStream<Stream> {
2321
/// A `TlsHandshake` implementation that uses OpenSSL.
2422
///
2523
/// Requires the `with-openssl` feature.
26-
#[derive(Debug)]
27-
pub struct OpenSsl(SslContext);
24+
pub struct OpenSsl(SslConnector);
25+
26+
impl fmt::Debug for OpenSsl {
27+
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
28+
fmt.debug_struct("OpenSsl").finish()
29+
}
30+
}
2831

2932
impl OpenSsl {
30-
/// Creates a `OpenSsl` with a reasonable default configuration.
31-
///
32-
/// The configuration is modeled after libcurl's and is subject to change.
33+
/// Creates a `OpenSsl` with `SslConnector`'s default configuration.
3334
pub fn new() -> Result<OpenSsl, ErrorStack> {
34-
let mut ctx = try!(SslContext::new(SslMethod::Sslv23));
35-
try!(ctx.set_default_verify_paths());
36-
ctx.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION);
37-
try!(ctx.set_cipher_list("ALL!EXPORT!EXPORT40!EXPORT56!aNULL!LOW!RC4@STRENGTH"));
38-
Ok(ctx.into())
35+
let connector = try!(SslConnectorBuilder::new(SslMethod::tls())).build();
36+
Ok(OpenSsl(connector))
3937
}
4038

41-
/// Returns a reference to the associated `SslContext`.
42-
pub fn context(&self) -> &SslContext {
39+
/// Returns a reference to the inner `SslConnector`.
40+
pub fn connector(&self) -> &SslConnector {
4341
&self.0
4442
}
4543

46-
/// Returns a mutable reference to the associated `SslContext`.
47-
pub fn context_mut(&mut self) -> &mut SslContext {
44+
/// Returns a mutable reference to the inner `SslConnector`.
45+
pub fn connector_mut(&mut self) -> &mut SslConnector {
4846
&mut self.0
4947
}
5048
}
5149

52-
impl From<SslContext> for OpenSsl {
53-
fn from(ctx: SslContext) -> OpenSsl {
54-
OpenSsl(ctx)
50+
impl From<SslConnector> for OpenSsl {
51+
fn from(connector: SslConnector) -> OpenSsl {
52+
OpenSsl(connector)
5553
}
5654
}
5755

@@ -60,10 +58,7 @@ impl TlsHandshake for OpenSsl {
6058
domain: &str,
6159
stream: Stream)
6260
-> Result<Box<TlsStream>, Box<Error + Send + Sync>> {
63-
let domain = domain.to_owned();
64-
let mut ssl = try!(self.0.into_ssl());
65-
ssl.set_verify_callback(SSL_VERIFY_PEER, move |p, x| verify_callback(&domain, p, x));
66-
let stream = try!(SslStream::connect(ssl, stream));
61+
let stream = try!(self.0.connect(domain, stream));
6762
Ok(Box::new(stream))
6863
}
6964
}

tests/test.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,12 @@ fn test_cancel_query() {
664664
#[test]
665665
#[cfg(feature = "with-openssl")]
666666
fn test_require_ssl_conn() {
667+
use openssl::ssl::{SslMethod, SslConnectorBuilder};
667668
use postgres::tls::openssl::OpenSsl;
668669

669-
let mut negotiator = OpenSsl::new().unwrap();
670-
negotiator.context_mut().set_CA_file(".travis/server.crt").unwrap();
670+
let mut builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
671+
builder.builder_mut().set_ca_file(".travis/server.crt").unwrap();
672+
let negotiator = OpenSsl::from(builder.build());
671673
let conn = or_panic!(Connection::connect("postgres://postgres@localhost",
672674
TlsMode::Require(&negotiator)));
673675
or_panic!(conn.execute("SELECT 1::VARCHAR", &[]));
@@ -676,10 +678,12 @@ fn test_require_ssl_conn() {
676678
#[test]
677679
#[cfg(feature = "with-openssl")]
678680
fn test_prefer_ssl_conn() {
681+
use openssl::ssl::{SslMethod, SslConnectorBuilder};
679682
use postgres::tls::openssl::OpenSsl;
680683

681-
let mut negotiator = OpenSsl::new().unwrap();
682-
negotiator.context_mut().set_CA_file(".travis/server.crt").unwrap();
684+
let mut builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
685+
builder.builder_mut().set_ca_file(".travis/server.crt").unwrap();
686+
let negotiator = OpenSsl::from(builder.build());
683687
let conn = or_panic!(Connection::connect("postgres://postgres@localhost",
684688
TlsMode::Require(&negotiator)));
685689
or_panic!(conn.execute("SELECT 1::VARCHAR", &[]));

0 commit comments

Comments
 (0)