mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Reorder and reorganise imports in net::connector
This commit is contained in:
parent
dc3765e231
commit
ecd9ac9b68
1 changed files with 22 additions and 22 deletions
|
@ -2,15 +2,34 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use hyper;
|
|
||||||
use hyper::client::Pool;
|
use hyper::client::Pool;
|
||||||
use hyper_openssl;
|
use hyper::net::HttpsConnector;
|
||||||
|
use hyper_openssl::OpensslClient;
|
||||||
use openssl::ssl::{SSL_OP_NO_COMPRESSION, SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3};
|
use openssl::ssl::{SSL_OP_NO_COMPRESSION, SSL_OP_NO_SSLV2, SSL_OP_NO_SSLV3};
|
||||||
use openssl::ssl::{SslConnectorBuilder, SslMethod};
|
use openssl::ssl::{SslConnectorBuilder, SslMethod};
|
||||||
use servo_config::resource_files::resources_dir_path;
|
use servo_config::resource_files::resources_dir_path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub type Connector = hyper::net::HttpsConnector<hyper_openssl::OpensslClient>;
|
pub type Connector = HttpsConnector<OpensslClient>;
|
||||||
|
|
||||||
|
pub fn create_http_connector(certificate_file: &str) -> Arc<Pool<Connector>> {
|
||||||
|
let ca_file = &resources_dir_path()
|
||||||
|
.expect("Need certificate file to make network requests")
|
||||||
|
.join(certificate_file);
|
||||||
|
|
||||||
|
let mut ssl_connector_builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
|
||||||
|
{
|
||||||
|
let context = ssl_connector_builder.builder_mut();
|
||||||
|
context.set_ca_file(ca_file).expect("could not set CA file");
|
||||||
|
context.set_cipher_list(DEFAULT_CIPHERS).expect("could not set ciphers");
|
||||||
|
context.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION);
|
||||||
|
}
|
||||||
|
let ssl_connector = ssl_connector_builder.build();
|
||||||
|
let ssl_client = OpensslClient::from(ssl_connector);
|
||||||
|
let https_connector = HttpsConnector::new(ssl_client);
|
||||||
|
|
||||||
|
Arc::new(Pool::with_connector(Default::default(), https_connector))
|
||||||
|
}
|
||||||
|
|
||||||
// The basic logic here is to prefer ciphers with ECDSA certificates, Forward
|
// The basic logic here is to prefer ciphers with ECDSA certificates, Forward
|
||||||
// Secrecy, AES GCM ciphers, AES ciphers, and finally 3DES ciphers.
|
// Secrecy, AES GCM ciphers, AES ciphers, and finally 3DES ciphers.
|
||||||
|
@ -27,22 +46,3 @@ const DEFAULT_CIPHERS: &'static str = concat!(
|
||||||
"ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:",
|
"ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:",
|
||||||
"AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA"
|
"AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA"
|
||||||
);
|
);
|
||||||
|
|
||||||
pub fn create_http_connector(certificate_file: &str) -> Arc<Pool<Connector>> {
|
|
||||||
let ca_file = &resources_dir_path()
|
|
||||||
.expect("Need certificate file to make network requests")
|
|
||||||
.join(certificate_file);
|
|
||||||
|
|
||||||
let mut ssl_connector_builder = SslConnectorBuilder::new(SslMethod::tls()).unwrap();
|
|
||||||
{
|
|
||||||
let context = ssl_connector_builder.builder_mut();
|
|
||||||
context.set_ca_file(ca_file).expect("could not set CA file");
|
|
||||||
context.set_cipher_list(DEFAULT_CIPHERS).expect("could not set ciphers");
|
|
||||||
context.set_options(SSL_OP_NO_SSLV2 | SSL_OP_NO_SSLV3 | SSL_OP_NO_COMPRESSION);
|
|
||||||
}
|
|
||||||
let ssl_connector = ssl_connector_builder.build();
|
|
||||||
let ssl_client = hyper_openssl::OpensslClient::from(ssl_connector);
|
|
||||||
let https_connector = hyper::net::HttpsConnector::new(ssl_client);
|
|
||||||
|
|
||||||
Arc::new(Pool::with_connector(Default::default(), https_connector))
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue