aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/ssl/tests
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-10-30 14:57:22 -0700
committerSteven Fackler <[email protected]>2016-10-30 14:57:22 -0700
commit52f288e090ef5d420ea0692c435c42c30570a957 (patch)
treec857f80bd5a6aac7915b7eb00b01d12fac7c31ed /openssl/src/ssl/tests
parentRename nwe to mozilla_intermediate (diff)
downloadrust-openssl-52f288e090ef5d420ea0692c435c42c30570a957.tar.xz
rust-openssl-52f288e090ef5d420ea0692c435c42c30570a957.zip
Add a mozilla modern profile
Diffstat (limited to 'openssl/src/ssl/tests')
-rw-r--r--openssl/src/ssl/tests/mod.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs
index 0c0c7957..eeada33a 100644
--- a/openssl/src/ssl/tests/mod.rs
+++ b/openssl/src/ssl/tests/mod.rs
@@ -1105,7 +1105,7 @@ fn connector_invalid_hostname() {
}
#[test]
-fn connector_client_server() {
+fn connector_client_server_mozilla_intermediate() {
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let port = listener.local_addr().unwrap().port();
@@ -1137,6 +1137,38 @@ fn connector_client_server() {
}
#[test]
+fn connector_client_server_mozilla_modern() {
+ let listener = TcpListener::bind("127.0.0.1:0").unwrap();
+ let port = listener.local_addr().unwrap().port();
+
+ let t = thread::spawn(move || {
+ let key = PKey::private_key_from_pem(KEY).unwrap();
+ let cert = X509::from_pem(CERT).unwrap();
+ let connector = ServerConnectorBuilder::mozilla_modern(
+ SslMethod::tls(), &key, &cert, None::<X509>)
+ .unwrap()
+ .build();
+ let stream = listener.accept().unwrap().0;
+ let mut stream = connector.connect(stream).unwrap();
+
+ stream.write_all(b"hello").unwrap();
+ });
+
+ let mut connector = ClientConnectorBuilder::new(SslMethod::tls()).unwrap();
+ connector.context_mut().set_CA_file("test/root-ca.pem").unwrap();
+ let connector = connector.build();
+
+ let stream = TcpStream::connect(("127.0.0.1", port)).unwrap();
+ let mut stream = connector.connect("foobar.com", stream).unwrap();
+
+ let mut buf = [0; 5];
+ stream.read_exact(&mut buf).unwrap();
+ assert_eq!(b"hello", &buf);
+
+ t.join().unwrap();
+}
+
+#[test]
fn shutdown() {
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let port = listener.local_addr().unwrap().port();