WIP cert authorities
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use clap::Parser;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Solar system central backend
|
||||
#[derive(Parser, Debug)]
|
||||
@ -9,6 +9,14 @@ pub struct AppConfig {
|
||||
#[arg(short, long, env, default_value = "0.0.0.0:8443")]
|
||||
listen_address: String,
|
||||
|
||||
/// The port the server will listen to (using HTTP, for unsecure connections)
|
||||
#[arg(short, long, env, default_value = "0.0.0.0:8080")]
|
||||
unsecure_listen_address: String,
|
||||
|
||||
/// Public server hostname (assuming that the ports used are the same for listen address)
|
||||
#[arg(short('H'), long, env, default_value = "localhost")]
|
||||
hostname: String,
|
||||
|
||||
/// Server storage path
|
||||
#[arg(short, long, env, default_value = "storage")]
|
||||
storage: String,
|
||||
@ -26,6 +34,23 @@ impl AppConfig {
|
||||
&ARGS
|
||||
}
|
||||
|
||||
/// URL for unsecure connections
|
||||
pub fn unsecure_origin(&self) -> String {
|
||||
format!(
|
||||
"http://{}:{}",
|
||||
self.hostname,
|
||||
self.unsecure_listen_address.split_once(':').unwrap().1
|
||||
)
|
||||
}
|
||||
|
||||
/// URL for secure connections
|
||||
pub fn secure_origin(&self) -> String {
|
||||
format!(
|
||||
"https://{}:{}",
|
||||
self.hostname,
|
||||
self.listen_address.split_once(':').unwrap().1
|
||||
)
|
||||
}
|
||||
|
||||
/// Get storage path
|
||||
pub fn storage_path(&self) -> PathBuf {
|
||||
@ -46,6 +71,26 @@ impl AppConfig {
|
||||
pub fn root_ca_priv_key_path(&self) -> PathBuf {
|
||||
self.pki_path().join("root_ca.key")
|
||||
}
|
||||
|
||||
/// Get PKI web CA cert path
|
||||
pub fn web_ca_cert_path(&self) -> PathBuf {
|
||||
self.pki_path().join("web_ca.pem")
|
||||
}
|
||||
|
||||
/// Get PKI web CA private key path
|
||||
pub fn web_ca_priv_key_path(&self) -> PathBuf {
|
||||
self.pki_path().join("web_ca.key")
|
||||
}
|
||||
|
||||
/// Get PKI devices CA cert path
|
||||
pub fn devices_ca_cert_path(&self) -> PathBuf {
|
||||
self.pki_path().join("devices_ca.pem")
|
||||
}
|
||||
|
||||
/// Get PKI devices CA private key path
|
||||
pub fn devices_ca_priv_key_path(&self) -> PathBuf {
|
||||
self.pki_path().join("devices_ca.key")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@ -57,4 +102,4 @@ mod test {
|
||||
use clap::CommandFactory;
|
||||
AppConfig::command().debug_assert()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user