index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2021-06-11 1:07:23.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2021-06-11 1:07:23.0 +00:00:00
commit
2b2da3a7c15111a6f114485357aad2b692f576c8 [patch]
tree
74b53e7450d2370fa7e8cc6518d08850392a1f8e
parent
50d3a377af5ec5c7b77befc8fb9466812ec5a201
download
2b2da3a7c15111a6f114485357aad2b692f576c8.tar.gz

refactor: --http2-tls-cert and --http2-tls-key requires --http2



Diff

 src/config.rs | 14 ++++++++++++--
 src/server.rs |  4 +++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/config.rs b/src/config.rs
index b94ca73..8efc362 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -81,11 +81,21 @@ pub struct Config {
    /// Enable HTTP/2 with TLS support.
    pub http2: bool,

    #[structopt(long, default_value = "", env = "SERVER_HTTP2_TLS_CERT")]
    #[structopt(
        long,
        required_if("http2", "true"),
        default_value = "",
        env = "SERVER_HTTP2_TLS_CERT"
    )]
    /// Specify the file path to read the certificate.
    pub http2_tls_cert: String,

    #[structopt(long, default_value = "", env = "SERVER_HTTP2_TLS_KEY")]
    #[structopt(
        long,
        required_if("http2", "true"),
        default_value = "",
        env = "SERVER_HTTP2_TLS_KEY"
    )]
    /// Specify the file path to read the private key.
    pub http2_tls_key: String,

diff --git a/src/server.rs b/src/server.rs
index b0bb735..bd8b555 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -137,7 +137,9 @@ impl Server {
                    .cert_path(cert_path)
                    .key_path(key_path)
                    .build()
                    .unwrap();
                    .expect(
                        "error during TLS server initialization, probably cert or key file missing",
                    );

                let server =
                    HyperServer::builder(TlsAcceptor::new(tls, incoming)).serve(router_service);