Repository: websockets-rs/rust-websocket (language: rust)

Issue:
SSL bound server errors on read_request
So I can't seem to get a secure socket server running correctly, each successful connection returns a "Bad file descriptor" error upon `read_request`. Strangely, the sample runs perfectly fine if I use `Server::bind` instead of `Server::bind_secure`. I've tested this on Ubuntu 15.04 64bit and OSX 10.10.5, the same issue persists.

I was also able to get an [Iron](https://github.com/iron/iron) server working with the same SSL certificates, so I'm fairly sure that hyper is not the issue here.

Example code: (You need a valid certificate saved as `certs/cert.pem` and key as `certs/privkey.pem`)

``` rust
extern crate websocket;
extern crate openssl;

use std::thread;
use std::path::Path;

use websocket::{Client, Message, Server};
use websocket::client::request::Url;

use openssl::ssl::{SslContext, SslMethod};
use openssl::x509::X509FileType;

fn main() {
    // Set up SSL
    let mut context = SslContext::new(SslMethod::Tlsv1).unwrap();
    let _ = context.set_certificate_file(Path::new("certs/cert.pem"), X509FileType::PEM);
    let _ = context.set_private_key_file(Path::new("certs/privkey.pem"), X509FileType::PEM);

    // Launch server
    let server = Server::bind_secure("0.0.0.0:1234", &context).unwrap();

    // New thread for client
    thread::spawn(|| {
        let url = Url::parse("wss://127.0.0.1:1234").unwrap(); // Socket URL
        let mut client = Client::connect(url).unwrap() // Fetch request
                                .send().unwrap()       // Fetch response
                                .begin();              // Get client

        // Send a hello world message
        let _ = client.send_message(&Message::text("Hello, World!"));
    });

    // Handle server connections
    for connection in server {
        let connection = connection.unwrap();

        // This will panic with "Bad file descriptor"
        let _request = connection.read_request().unwrap();

        // ...
    }
}

```



Discussion / hints:
Sorry @overdrivenpotato I was going to look into this but I have too much work this week. I will try to get to this soon.

Alright @illegalprime I appreciate it!

_Update_: Seems to crash on rust 1.5 with `An unknown error occurred`. Running with `--verbose` gives `signal: 11`, so now it segfaults rather than giving a bad file descriptor error.
Tested again on OSX 10.10.5 and Ubuntu 15.04


Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 6b7940c97f..5270f3a505 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,7 +19,7 @@ license = "MIT"
 [dependencies]
 hyper = "0.7"
 unicase = "1.0.1"
-openssl = "0.7.0"
+openssl = "0.7.6"
 url = "0.5.0"
 rustc-serialize = "0.3.16"
 bitflags = "0.3.3"


Test patch: