aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--README.md2
-rw-r--r--openssl-sys/Cargo.toml2
-rw-r--r--openssl-sys/build.rs7
-rw-r--r--openssl-sys/src/lib.rs3
-rw-r--r--openssl/Cargo.toml4
-rw-r--r--openssl/src/ssl/mod.rs28
-rw-r--r--openssl/src/ssl/tests.rs31
-rw-r--r--openssl/src/x509/tests.rs1
9 files changed, 59 insertions, 24 deletions
diff --git a/.travis.yml b/.travis.yml
index 82f95481..b302c491 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,7 @@
language: rust
+rust:
+- nightly
+- beta
os:
- osx
- linux
@@ -15,4 +18,4 @@ script:
- (test $TRAVIS_OS_NAME == "osx" || (cd openssl && LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH cargo test --features "$FEATURES"))
- ./.travis/build_docs.sh
after_success:
-- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && ./.travis/update_docs.sh
+- test $TRAVIS_PULL_REQUEST == "false" && test $TRAVIS_BRANCH == "master" && test $TRAVIS_RUST_VERSION == "nightly" && ./.travis/update_docs.sh
diff --git a/README.md b/README.md
index d38ead28..8843ef9a 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ rust-openssl directory. Then run one of the following commands:
* Windows: `openssl s_server -accept 15418 -www -cert test/cert.pem -key
test/key.pem > NUL`
-* Linux: `openssl s_server -accept 15418 -www -cert test/cert.pem -key \
+* Linux: `openssl s_server -accept 15418 -www -cert test/cert.pem -key
test/key.pem >/dev/null`
Then in the original terminal, run `cargo test`. If everything is set up
diff --git a/openssl-sys/Cargo.toml b/openssl-sys/Cargo.toml
index 5c37c054..fd1e425a 100644
--- a/openssl-sys/Cargo.toml
+++ b/openssl-sys/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "openssl-sys"
-version = "0.6.0"
+version = "0.6.2"
authors = ["Alex Crichton <[email protected]>",
"Steven Fackler <[email protected]>"]
license = "MIT"
diff --git a/openssl-sys/build.rs b/openssl-sys/build.rs
index e0d88309..aadaa361 100644
--- a/openssl-sys/build.rs
+++ b/openssl-sys/build.rs
@@ -5,6 +5,11 @@ use std::env;
use std::path::PathBuf;
fn main() {
+ let target = env::var("TARGET").unwrap();
+
+ // libressl_pnacl_sys links the libs needed.
+ if target.ends_with("nacl") { return; }
+
let lib_dir = env::var("OPENSSL_LIB_DIR").ok();
let include_dir = env::var("OPENSSL_INCLUDE_DIR").ok();
@@ -15,7 +20,7 @@ fn main() {
}
}
- let (libcrypto, libssl) = if env::var("TARGET").unwrap().contains("windows") {
+ let (libcrypto, libssl) = if target.contains("windows") {
("eay32", "ssl32")
} else {
("crypto", "ssl")
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index 598a3c59..9365704e 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -440,8 +440,11 @@ extern "C" {
pub fn HMAC_CTX_copy(dst: *mut HMAC_CTX, src: *const HMAC_CTX) -> c_int;
// Pre-1.0 versions of these didn't return anything, so the shims bridge that gap
+ #[cfg_attr(target_os = "nacl", link_name = "HMAC_Init_ex")]
pub fn HMAC_Init_ex_shim(ctx: *mut HMAC_CTX, key: *const u8, keylen: c_int, md: *const EVP_MD, imple: *const ENGINE) -> c_int;
+ #[cfg_attr(target_os = "nacl", link_name = "HMAC_Final")]
pub fn HMAC_Final_shim(ctx: *mut HMAC_CTX, output: *mut u8, len: *mut c_uint) -> c_int;
+ #[cfg_attr(target_os = "nacl", link_name = "HMAC_Update")]
pub fn HMAC_Update_shim(ctx: *mut HMAC_CTX, input: *const u8, len: c_uint) -> c_int;
diff --git a/openssl/Cargo.toml b/openssl/Cargo.toml
index 38ca4545..2f5fe207 100644
--- a/openssl/Cargo.toml
+++ b/openssl/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "openssl"
-version = "0.6.0"
+version = "0.6.2"
authors = ["Steven Fackler <[email protected]>"]
license = "Apache-2.0"
description = "OpenSSL bindings"
@@ -20,7 +20,7 @@ npn = ["openssl-sys/npn"]
[dependencies.openssl-sys]
path = "../openssl-sys"
-version = "0.6.0"
+version = "0.6.2"
[dependencies]
bitflags = "0.1.1"
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 26851ade..b5a138dd 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -431,8 +431,8 @@ impl SslContext {
#[allow(non_snake_case)]
/// Specifies the file that contains trusted CA certificates.
- pub fn set_CA_file(&mut self, file: &Path) -> Result<(),SslError> {
- let file = CString::new(file.as_os_str().to_str().expect("invalid utf8")).unwrap();
+ pub fn set_CA_file<P: AsRef<Path>>(&mut self, file: P) -> Result<(),SslError> {
+ let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
wrap_ssl_result(
unsafe {
ffi::SSL_CTX_load_verify_locations(self.ctx, file.as_ptr(), ptr::null())
@@ -440,9 +440,9 @@ impl SslContext {
}
/// Specifies the file that contains certificate
- pub fn set_certificate_file(&mut self, file: &Path,
- file_type: X509FileType) -> Result<(),SslError> {
- let file = CString::new(file.as_os_str().to_str().expect("invalid utf8")).unwrap();
+ pub fn set_certificate_file<P: AsRef<Path>>(&mut self, file: P, file_type: X509FileType)
+ -> Result<(),SslError> {
+ let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
wrap_ssl_result(
unsafe {
ffi::SSL_CTX_use_certificate_file(self.ctx, file.as_ptr(), file_type as c_int)
@@ -467,9 +467,9 @@ impl SslContext {
}
/// Specifies the file that contains private key
- pub fn set_private_key_file(&mut self, file: &Path,
+ pub fn set_private_key_file<P: AsRef<Path>>(&mut self, file: P,
file_type: X509FileType) -> Result<(),SslError> {
- let file = CString::new(file.as_os_str().to_str().expect("invalid utf8")).unwrap();
+ let file = CString::new(file.as_ref().as_os_str().to_str().expect("invalid utf8")).unwrap();
wrap_ssl_result(
unsafe {
ffi::SSL_CTX_use_PrivateKey_file(self.ctx, file.as_ptr(), file_type as c_int)
@@ -899,14 +899,14 @@ impl<S: Read+Write> Read for SslStream<S> {
impl<S: Read+Write> Write for SslStream<S> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- match self.in_retry_wrapper(|ssl| ssl.write(buf)) {
- Ok(len) => Ok(len as usize),
- Err(SslSessionClosed) => Ok(0),
+ let count = match self.in_retry_wrapper(|ssl| ssl.write(buf)) {
+ Ok(len) => len as usize,
+ Err(SslSessionClosed) => 0,
Err(StreamError(e)) => return Err(e),
- Err(e @ OpenSslErrors(_)) => {
- Err(io::Error::new(io::ErrorKind::Other, e))
- }
- }
+ Err(e @ OpenSslErrors(_)) => return Err(io::Error::new(io::ErrorKind::Other, e)),
+ };
+ try!(self.write_through());
+ Ok(count)
}
fn flush(&mut self) -> io::Result<()> {
diff --git a/openssl/src/ssl/tests.rs b/openssl/src/ssl/tests.rs
index 688a5db6..e6af551b 100644
--- a/openssl/src/ssl/tests.rs
+++ b/openssl/src/ssl/tests.rs
@@ -4,9 +4,7 @@ use std::net::TcpStream;
use std::io;
use std::io::prelude::*;
use std::path::Path;
-#[cfg(feature = "npn")]
use std::net::TcpListener;
-#[cfg(feature = "npn")]
use std::thread;
use std::fs::File;
@@ -17,7 +15,6 @@ use ssl::SslMethod::Sslv23;
use ssl::{SslContext, SslStream, VerifyCallback};
use ssl::SSL_VERIFY_PEER;
use x509::X509StoreContext;
-#[cfg(feature = "npn")]
use x509::X509FileType;
use x509::X509;
use crypto::pkey::PKey;
@@ -237,6 +234,34 @@ run_test!(verify_callback_data, |method, stream| {
}
});
+// Make sure every write call translates to a write call to the underlying socket.
+#[test]
+fn test_write_hits_stream() {
+ let listener = TcpListener::bind("localhost:0").unwrap();
+ let addr = listener.local_addr().unwrap();
+
+ let guard = thread::spawn(move || {
+ let ctx = SslContext::new(Sslv23).unwrap();
+ let stream = TcpStream::connect(addr).unwrap();
+ let mut stream = SslStream::new(&ctx, stream).unwrap();
+
+ stream.write_all(b"hello").unwrap();
+ stream
+ });
+
+ let mut ctx = SslContext::new(Sslv23).unwrap();
+ ctx.set_verify(SSL_VERIFY_PEER, None);
+ ctx.set_certificate_file(&Path::new("test/cert.pem"), X509FileType::PEM).unwrap();
+ ctx.set_private_key_file(&Path::new("test/key.pem"), X509FileType::PEM).unwrap();
+ let stream = listener.accept().unwrap().0;
+ let mut stream = SslStream::new_server(&ctx, stream).unwrap();
+
+ let mut buf = [0; 5];
+ assert_eq!(5, stream.read(&mut buf).unwrap());
+ assert_eq!(&b"hello"[..], &buf[..]);
+ guard.join().unwrap();
+}
+
#[test]
fn test_set_certificate_and_private_key() {
let key_path = Path::new("test/key.pem");
diff --git a/openssl/src/x509/tests.rs b/openssl/src/x509/tests.rs
index 1788b556..e9a8a4a5 100644
--- a/openssl/src/x509/tests.rs
+++ b/openssl/src/x509/tests.rs
@@ -2,7 +2,6 @@ use serialize::hex::FromHex;
use std::io;
use std::path::Path;
use std::fs::File;
-use std::str;
use crypto::hash::Type::{SHA256};
use x509::{X509, X509Generator};