Use env vars for TLS files
This commit is contained in:
@@ -2,7 +2,6 @@ application:
|
|||||||
port: 8000
|
port: 8000
|
||||||
host: "127.0.0.1"
|
host: "127.0.0.1"
|
||||||
base_url: "http://127.0.0.1:8000"
|
base_url: "http://127.0.0.1:8000"
|
||||||
require_tls: false
|
|
||||||
database:
|
database:
|
||||||
host: "127.0.0.1"
|
host: "127.0.0.1"
|
||||||
port: 5432
|
port: 5432
|
||||||
@@ -13,3 +12,4 @@ database:
|
|||||||
email_client:
|
email_client:
|
||||||
authorization_token: "secret-token"
|
authorization_token: "secret-token"
|
||||||
redis_uri: "redis://127.0.0.1:6379"
|
redis_uri: "redis://127.0.0.1:6379"
|
||||||
|
require_tls: false
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ pub struct Settings {
|
|||||||
pub database: DatabaseSettings,
|
pub database: DatabaseSettings,
|
||||||
pub email_client: EmailClientSettings,
|
pub email_client: EmailClientSettings,
|
||||||
pub redis_uri: SecretString,
|
pub redis_uri: SecretString,
|
||||||
|
pub require_tls: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
@@ -69,7 +70,6 @@ pub struct ApplicationSettings {
|
|||||||
pub port: u16,
|
pub port: u16,
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub base_url: String,
|
pub base_url: String,
|
||||||
pub require_tls: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
|
|||||||
@@ -62,14 +62,16 @@ impl Application {
|
|||||||
configuration.application.base_url,
|
configuration.application.base_url,
|
||||||
redis_store,
|
redis_store,
|
||||||
);
|
);
|
||||||
let tls_config = if configuration.application.require_tls {
|
let tls_config = if configuration.require_tls {
|
||||||
Some(
|
Some(
|
||||||
RustlsConfig::from_pem_file(
|
RustlsConfig::from_pem_file(
|
||||||
"/home/alphonse/.certs/fullchain.pem",
|
std::env::var("APP_TLS_CERT")
|
||||||
"/home/alphonse/.certs/privkey.pem",
|
.expect("Failed to read TLS certificate environment variable"),
|
||||||
|
std::env::var("APP_TLS_KEY")
|
||||||
|
.expect("Feiled to read TLS private key environment variable"),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.expect("Could not create TLS configuration"),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
Reference in New Issue
Block a user