Merge branch 'release-v0.7.4' into release
This commit is contained in:
commit
3fdfe56f25
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export CARGO_TARGET_DIR=target
|
||||||
|
|
||||||
|
for toml in $(find . -maxdepth 2 -name "Cargo.toml"); do
|
||||||
|
cargo update --manifest-path $toml || true
|
||||||
|
features=$(cargo read-manifest --manifest-path $toml | jq -r '.features|keys|join(" ")')
|
||||||
|
cargo doc --no-deps --manifest-path $toml --features "$features"
|
||||||
|
done
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[package]
|
[package]
|
||||||
name = "openssl-sys-extras"
|
name = "openssl-sys-extras"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "Extra FFI bindings to OpenSSL that require a C shim"
|
description = "Extra FFI bindings to OpenSSL that require a C shim"
|
||||||
repository = "https://github.com/sfackler/rust-openssl"
|
repository = "https://github.com/sfackler/rust-openssl"
|
||||||
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.3/openssl_sys_extras"
|
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.4/openssl_sys_extras"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
@ -13,7 +13,7 @@ ecdh_auto = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
openssl-sys = { version = "0.7.3", path = "../openssl-sys" }
|
openssl-sys = { version = "0.7.4", path = "../openssl-sys" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gcc = "0.3"
|
gcc = "0.3"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#![allow(non_upper_case_globals, non_snake_case)]
|
#![allow(non_upper_case_globals, non_snake_case)]
|
||||||
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.3")]
|
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.4")]
|
||||||
|
|
||||||
extern crate openssl_sys;
|
extern crate openssl_sys;
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
authors = ["Alex Crichton <alex@alexcrichton.com>",
|
authors = ["Alex Crichton <alex@alexcrichton.com>",
|
||||||
"Steven Fackler <sfackler@gmail.com>"]
|
"Steven Fackler <sfackler@gmail.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "FFI bindings to OpenSSL"
|
description = "FFI bindings to OpenSSL"
|
||||||
repository = "https://github.com/sfackler/rust-openssl"
|
repository = "https://github.com/sfackler/rust-openssl"
|
||||||
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.3/openssl_sys"
|
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.4/openssl_sys"
|
||||||
links = "openssl"
|
links = "openssl"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
|
|
@ -40,15 +40,15 @@ libressl-pnacl-sys = "2.1.0"
|
||||||
libressl-pnacl-sys = "2.1.0"
|
libressl-pnacl-sys = "2.1.0"
|
||||||
|
|
||||||
# Only here to make sure we link to these in a static build on Windows
|
# Only here to make sure we link to these in a static build on Windows
|
||||||
[target.i686-pc-windows-gnu]
|
[target.i686-pc-windows-gnu.dependencies]
|
||||||
user32-sys = "0.1"
|
user32-sys = "0.1"
|
||||||
gdi32-sys = "0.1"
|
gdi32-sys = "0.1"
|
||||||
[target.x86_64-pc-windows-gnu]
|
[target.x86_64-pc-windows-gnu.dependencies]
|
||||||
user32-sys = "0.1"
|
user32-sys = "0.1"
|
||||||
gdi32-sys = "0.1"
|
gdi32-sys = "0.1"
|
||||||
[target.i686-pc-windows-msvc]
|
[target.i686-pc-windows-msvc.dependencies]
|
||||||
user32-sys = "0.1"
|
user32-sys = "0.1"
|
||||||
gdi32-sys = "0.1"
|
gdi32-sys = "0.1"
|
||||||
[target.x86_64-pc-windows-msvc]
|
[target.x86_64-pc-windows-msvc.dependencies]
|
||||||
user32-sys = "0.1"
|
user32-sys = "0.1"
|
||||||
gdi32-sys = "0.1"
|
gdi32-sys = "0.1"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
|
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.3")]
|
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.4")]
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
[package]
|
[package]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.7.3"
|
version = "0.7.4"
|
||||||
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
authors = ["Steven Fackler <sfackler@gmail.com>"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
description = "OpenSSL bindings"
|
description = "OpenSSL bindings"
|
||||||
repository = "https://github.com/sfackler/rust-openssl"
|
repository = "https://github.com/sfackler/rust-openssl"
|
||||||
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.3/openssl"
|
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.4/openssl"
|
||||||
readme = "../README.md"
|
readme = "../README.md"
|
||||||
keywords = ["crypto", "tls", "ssl", "dtls"]
|
keywords = ["crypto", "tls", "ssl", "dtls"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
@ -29,8 +29,8 @@ pkcs5_pbkdf2_hmac = ["openssl-sys/pkcs5_pbkdf2_hmac"]
|
||||||
bitflags = ">= 0.2, < 0.4"
|
bitflags = ">= 0.2, < 0.4"
|
||||||
lazy_static = "0.1"
|
lazy_static = "0.1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
openssl-sys = { version = "0.7.3", path = "../openssl-sys" }
|
openssl-sys = { version = "0.7.4", path = "../openssl-sys" }
|
||||||
openssl-sys-extras = { version = "0.7.3", path = "../openssl-sys-extras" }
|
openssl-sys-extras = { version = "0.7.4", path = "../openssl-sys-extras" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gcc = "0.3"
|
gcc = "0.3"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.3")]
|
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.4")]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate bitflags;
|
extern crate bitflags;
|
||||||
|
|
|
||||||
|
|
@ -6,35 +6,20 @@ use std::io::prelude::*;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use ssl::error::SslError;
|
use ssl::error::SslError;
|
||||||
|
|
||||||
// "rust"
|
// "rust"
|
||||||
const NAME: [c_char; 5] = [114, 117, 115, 116, 0];
|
const NAME: [c_char; 5] = [114, 117, 115, 116, 0];
|
||||||
|
|
||||||
// we use this after removing the stream from the BIO so that we don't have to
|
|
||||||
// worry about freeing the heap allocated BIO_METHOD after freeing the BIO.
|
|
||||||
static DESTROY_METHOD: BIO_METHOD = BIO_METHOD {
|
|
||||||
type_: BIO_TYPE_NONE,
|
|
||||||
name: &NAME[0],
|
|
||||||
bwrite: None,
|
|
||||||
bread: None,
|
|
||||||
bputs: None,
|
|
||||||
bgets: None,
|
|
||||||
ctrl: None,
|
|
||||||
create: None,
|
|
||||||
destroy: Some(destroy),
|
|
||||||
callback_ctrl: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub struct StreamState<S> {
|
pub struct StreamState<S> {
|
||||||
pub stream: S,
|
pub stream: S,
|
||||||
pub error: Option<io::Error>,
|
pub error: Option<io::Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<S: Read + Write>(stream: S) -> Result<(*mut BIO, Box<BIO_METHOD>), SslError> {
|
pub fn new<S: Read + Write>(stream: S) -> Result<(*mut BIO, Arc<BIO_METHOD>), SslError> {
|
||||||
|
let method = Arc::new(BIO_METHOD {
|
||||||
let method = Box::new(BIO_METHOD {
|
|
||||||
type_: BIO_TYPE_NONE,
|
type_: BIO_TYPE_NONE,
|
||||||
name: &NAME[0],
|
name: &NAME[0],
|
||||||
bwrite: Some(bwrite::<S>),
|
bwrite: Some(bwrite::<S>),
|
||||||
|
|
@ -43,7 +28,7 @@ pub fn new<S: Read + Write>(stream: S) -> Result<(*mut BIO, Box<BIO_METHOD>), Ss
|
||||||
bgets: None,
|
bgets: None,
|
||||||
ctrl: Some(ctrl::<S>),
|
ctrl: Some(ctrl::<S>),
|
||||||
create: Some(create),
|
create: Some(create),
|
||||||
destroy: None, // covered in the replacement BIO_METHOD
|
destroy: Some(destroy::<S>),
|
||||||
callback_ctrl: None,
|
callback_ctrl: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -66,14 +51,6 @@ pub unsafe fn take_error<S>(bio: *mut BIO) -> Option<io::Error> {
|
||||||
state.error.take()
|
state.error.take()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn take_stream<S>(bio: *mut BIO) -> S {
|
|
||||||
let state: Box<StreamState<S>> = Box::from_raw((*bio).ptr as *mut _);
|
|
||||||
(*bio).ptr = ptr::null_mut();
|
|
||||||
(*bio).method = &DESTROY_METHOD as *const _ as *mut _;
|
|
||||||
(*bio).init = 0;
|
|
||||||
state.stream
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn get_ref<'a, S: 'a>(bio: *mut BIO) -> &'a S {
|
pub unsafe fn get_ref<'a, S: 'a>(bio: *mut BIO) -> &'a S {
|
||||||
let state: &'a StreamState<S> = mem::transmute((*bio).ptr);
|
let state: &'a StreamState<S> = mem::transmute((*bio).ptr);
|
||||||
&state.stream
|
&state.stream
|
||||||
|
|
@ -124,7 +101,7 @@ unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int)
|
||||||
fn retriable_error(err: &io::Error) -> bool {
|
fn retriable_error(err: &io::Error) -> bool {
|
||||||
match err.kind() {
|
match err.kind() {
|
||||||
io::ErrorKind::WouldBlock | io::ErrorKind::NotConnected => true,
|
io::ErrorKind::WouldBlock | io::ErrorKind::NotConnected => true,
|
||||||
_ => false
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,11 +136,14 @@ unsafe extern "C" fn create(bio: *mut BIO) -> c_int {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn destroy(bio: *mut BIO) -> c_int {
|
unsafe extern "C" fn destroy<S>(bio: *mut BIO) -> c_int {
|
||||||
if bio.is_null() {
|
if bio.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!((*bio).ptr.is_null());
|
assert!(!(*bio).ptr.is_null());
|
||||||
|
Box::<StreamState<S>>::from_raw((*bio).ptr as *mut _);
|
||||||
|
(*bio).ptr = ptr::null_mut();
|
||||||
|
(*bio).init = 0;
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use std::str;
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::{Once, ONCE_INIT, Mutex};
|
use std::sync::{Once, ONCE_INIT, Mutex, Arc};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
#[cfg(any(feature = "npn", feature = "alpn"))]
|
#[cfg(any(feature = "npn", feature = "alpn"))]
|
||||||
|
|
@ -778,6 +778,7 @@ impl Drop for Ssl {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Ssl {
|
impl Clone for Ssl {
|
||||||
|
/// # Deprecated
|
||||||
fn clone(&self) -> Ssl {
|
fn clone(&self) -> Ssl {
|
||||||
unsafe { rust_SSL_clone(self.ssl) };
|
unsafe { rust_SSL_clone(self.ssl) };
|
||||||
Ssl { ssl: self.ssl }
|
Ssl { ssl: self.ssl }
|
||||||
|
|
@ -1003,23 +1004,22 @@ make_LibSslError! {
|
||||||
/// A stream wrapper which handles SSL encryption for an underlying stream.
|
/// A stream wrapper which handles SSL encryption for an underlying stream.
|
||||||
pub struct SslStream<S> {
|
pub struct SslStream<S> {
|
||||||
ssl: Ssl,
|
ssl: Ssl,
|
||||||
_method: Box<ffi::BIO_METHOD>, // :(
|
_method: Arc<ffi::BIO_METHOD>, // NOTE: this *must* be after the Ssl field so things drop right
|
||||||
_p: PhantomData<S>,
|
_p: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<S: Send> Send for SslStream<S> {}
|
unsafe impl<S: Send> Send for SslStream<S> {}
|
||||||
|
|
||||||
|
/// # Deprecated
|
||||||
|
///
|
||||||
|
/// This method does not behave as expected and will be removed in a future
|
||||||
|
/// release.
|
||||||
impl<S: Clone + Read + Write> Clone for SslStream<S> {
|
impl<S: Clone + Read + Write> Clone for SslStream<S> {
|
||||||
fn clone(&self) -> SslStream<S> {
|
fn clone(&self) -> SslStream<S> {
|
||||||
let stream = self.get_ref().clone();
|
SslStream {
|
||||||
Self::new_base(self.ssl.clone(), stream)
|
ssl: self.ssl.clone(),
|
||||||
}
|
_method: self._method.clone(),
|
||||||
}
|
_p: PhantomData,
|
||||||
|
|
||||||
impl<S> Drop for SslStream<S> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
let _ = bio::take_stream::<S>(self.ssl.get_raw_rbio());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1232,10 +1232,16 @@ impl<S> SslStream<S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SslStream<::std::net::TcpStream> {
|
impl SslStream<::std::net::TcpStream> {
|
||||||
/// Like `TcpStream::try_clone`.
|
/// # Deprecated
|
||||||
|
///
|
||||||
|
/// This method does not behave as expected and will be removed in a future
|
||||||
|
/// release.
|
||||||
pub fn try_clone(&self) -> io::Result<SslStream<::std::net::TcpStream>> {
|
pub fn try_clone(&self) -> io::Result<SslStream<::std::net::TcpStream>> {
|
||||||
let stream = try!(self.get_ref().try_clone());
|
Ok(SslStream {
|
||||||
Ok(Self::new_base(self.ssl.clone(), stream))
|
ssl: self.ssl.clone(),
|
||||||
|
_method: self._method.clone(),
|
||||||
|
_p: PhantomData,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -949,3 +949,11 @@ fn test_read_nonblocking() {
|
||||||
assert!(bytes_read >= 5);
|
assert!(bytes_read >= 5);
|
||||||
assert_eq!(&input_buffer[..5], b"HTTP/");
|
assert_eq!(&input_buffer[..5], b"HTTP/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn broken_try_clone_doesnt_crash() {
|
||||||
|
let context = SslContext::new(SslMethod::Sslv23).unwrap();
|
||||||
|
let inner = TcpStream::connect("example.com:443").unwrap();
|
||||||
|
let stream1 = SslStream::connect(&context, inner).unwrap();
|
||||||
|
let _stream2 = stream1.try_clone().unwrap();
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue