mirror of
https://github.com/rwf2/Rocket.git
synced 2025-01-07 10:12:36 +00:00
614f8ab46c
Previously, TLS, via 'Config::tls', was configurable even if the 'tls' feature was disabled. This commit changes this so that the 'Config::tls' field and TLS config structures are only available if 'tls' is enabled.
24 lines
784 B
Rust
24 lines
784 B
Rust
#![cfg(feature = "tls")]
|
|
|
|
use rocket::fs::relative;
|
|
use rocket::config::{Config, TlsConfig, CipherSuite};
|
|
use rocket::local::asynchronous::Client;
|
|
|
|
#[rocket::async_test]
|
|
async fn can_launch_tls() {
|
|
let cert_path = relative!("examples/tls/private/rsa_sha256_cert.pem");
|
|
let key_path = relative!("examples/tls/private/rsa_sha256_key.pem");
|
|
|
|
let tls = TlsConfig::from_paths(cert_path, key_path)
|
|
.with_ciphers([
|
|
CipherSuite::TLS_AES_128_GCM_SHA256,
|
|
CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
|
|
]);
|
|
|
|
let rocket = rocket::custom(Config { tls: Some(tls), ..Config::debug_default() });
|
|
let client = Client::debug(rocket).await.unwrap();
|
|
|
|
client.rocket().shutdown().notify();
|
|
client.rocket().shutdown().await;
|
|
}
|