aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl
diff options
context:
space:
mode:
Diffstat (limited to 'openssl/src/ssl')
-rw-r--r--openssl/src/ssl/connector.rs16
-rw-r--r--openssl/src/ssl/error.rs9
-rw-r--r--openssl/src/ssl/test.rs5
3 files changed, 26 insertions, 4 deletions
diff --git a/openssl/src/ssl/connector.rs b/openssl/src/ssl/connector.rs
index 54910733..9e485ab9 100644
--- a/openssl/src/ssl/connector.rs
+++ b/openssl/src/ssl/connector.rs
@@ -124,11 +124,22 @@ pub struct ConnectConfiguration {
}
impl ConnectConfiguration {
+ /// A builder-style version of `set_use_server_name_indication`.
+ pub fn use_server_name_indication(mut self, use_sni: bool) -> ConnectConfiguration {
+ self.set_use_server_name_indication(use_sni);
+ self
+ }
+
/// Configures the use of Server Name Indication (SNI) when connecting.
///
/// Defaults to `true`.
- pub fn use_server_name_indication(mut self, use_sni: bool) -> ConnectConfiguration {
+ pub fn set_use_server_name_indication(&mut self, use_sni: bool) {
self.sni = use_sni;
+ }
+
+ /// A builder-style version of `set_verify_hostname`.
+ pub fn verify_hostname(mut self, verify_hostname: bool) -> ConnectConfiguration {
+ self.set_verify_hostname(verify_hostname);
self
}
@@ -141,9 +152,8 @@ impl ConnectConfiguration {
/// You should think very carefully before you use this method. If hostname verification is not
/// used, *any* valid certificate for *any* site will be trusted for use from any other. This
/// introduces a significant vulnerability to man-in-the-middle attacks.
- pub fn verify_hostname(mut self, verify_hostname: bool) -> ConnectConfiguration {
+ pub fn set_verify_hostname(&mut self, verify_hostname: bool) {
self.verify_hostname = verify_hostname;
- self
}
/// Initiates a client-side TLS session on a stream.
diff --git a/openssl/src/ssl/error.rs b/openssl/src/ssl/error.rs
index c0bc80ae..18e44cd6 100644
--- a/openssl/src/ssl/error.rs
+++ b/openssl/src/ssl/error.rs
@@ -82,6 +82,15 @@ impl Error {
}
}
+impl From<ErrorStack> for Error {
+ fn from(e: ErrorStack) -> Error {
+ Error {
+ code: ErrorCode::SSL,
+ cause: Some(InnerError::Ssl(e)),
+ }
+ }
+}
+
impl fmt::Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self.code {
diff --git a/openssl/src/ssl/test.rs b/openssl/src/ssl/test.rs
index db478d36..dc58c4fa 100644
--- a/openssl/src/ssl/test.rs
+++ b/openssl/src/ssl/test.rs
@@ -82,11 +82,14 @@ impl Server {
}
fn new_tcp(args: &[&str]) -> (Server, TcpStream) {
- let (server, addr) = Server::spawn(args, None);
+ let (mut server, addr) = Server::spawn(args, None);
for _ in 0..20 {
match TcpStream::connect(&addr) {
Ok(s) => return (server, s),
Err(ref e) if e.kind() == io::ErrorKind::ConnectionRefused => {
+ if let Some(exit_status) = server.p.try_wait().expect("try_wait") {
+ panic!("server exited: {}", exit_status);
+ }
thread::sleep(Duration::from_millis(100));
}
Err(e) => panic!("wut: {}", e),