From d5d4cb9e63961f44cfc2758a244afcd04f45f33a Mon Sep 17 00:00:00 2001 From: badaix Date: Thu, 26 Dec 2024 22:58:41 +0100 Subject: [PATCH] Rename "private_key" to "certificate_key" --- server/authinfo.cpp | 6 +++--- server/control_server.cpp | 4 ++-- server/control_session_http.cpp | 1 - server/etc/snapserver.conf | 4 ++-- server/server_settings.hpp | 2 +- server/snapserver.cpp | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/server/authinfo.cpp b/server/authinfo.cpp index 57e0441d..c743bb8b 100644 --- a/server/authinfo.cpp +++ b/server/authinfo.cpp @@ -188,12 +188,12 @@ ErrorOr AuthInfo::getToken(const std::string& username, const std:: jwt.setIat(now); jwt.setExp(now + 10h); jwt.setSub(username); - std::ifstream ifs(settings_.ssl.private_key); - std::string private_key((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); + std::ifstream ifs(settings_.ssl.certificate_key); + std::string certificate_key((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); if (!ifs.good()) return ErrorCode{std::make_error_code(std::errc::io_error), "Failed to read private key file"}; // TODO tls: eroor handling - std::optional token = jwt.getToken(private_key); + std::optional token = jwt.getToken(certificate_key); if (!token.has_value()) return ErrorCode{AuthErrc::failed_to_create_token}; return token.value(); diff --git a/server/control_server.cpp b/server/control_server.cpp index c60808c9..d3454586 100644 --- a/server/control_server.cpp +++ b/server/control_server.cpp @@ -55,10 +55,10 @@ ControlServer::ControlServer(boost::asio::io_context& io_context, const ServerSe return pw; }); } - if (!ssl.certificate.empty() && !ssl.private_key.empty()) + if (!ssl.certificate.empty() && !ssl.certificate_key.empty()) { ssl_context_.use_certificate_chain_file(ssl.certificate); - ssl_context_.use_private_key_file(ssl.private_key, boost::asio::ssl::context::pem); + ssl_context_.use_private_key_file(ssl.certificate_key, boost::asio::ssl::context::pem); } // ssl_context_.use_tmp_dh_file("dh4096.pem"); } diff --git a/server/control_session_http.cpp b/server/control_session_http.cpp index 1a42396b..8ad6b6ef 100644 --- a/server/control_session_http.cpp +++ b/server/control_session_http.cpp @@ -20,7 +20,6 @@ #include "control_session_http.hpp" // local headers -#include "authinfo.hpp" #include "common/aixlog.hpp" #include "common/utils/file_utils.hpp" #include "control_session_ws.hpp" diff --git a/server/etc/snapserver.conf b/server/etc/snapserver.conf index e69b711f..5fc2c0e2 100644 --- a/server/etc/snapserver.conf +++ b/server/etc/snapserver.conf @@ -57,9 +57,9 @@ # certificate = # Private key file in PEM format -# private_key = +# certificate_key = -# Password for decryption of the private_key (only needed for encrypted private_key file) +# Password for decryption of the certificate_key (only needed for encrypted certificate_key file) # key_password = # diff --git a/server/server_settings.hpp b/server/server_settings.hpp index 860d39f7..bf488a00 100644 --- a/server/server_settings.hpp +++ b/server/server_settings.hpp @@ -42,7 +42,7 @@ struct ServerSettings struct Ssl { std::string certificate{""}; - std::string private_key{""}; + std::string certificate_key{""}; std::string key_password{""}; }; diff --git a/server/snapserver.cpp b/server/snapserver.cpp index 2dadf90a..a5039c2b 100644 --- a/server/snapserver.cpp +++ b/server/snapserver.cpp @@ -82,7 +82,7 @@ int main(int argc, char* argv[]) // SSL settings conf.add>("", "ssl.certificate", "certificate file (PEM format)", settings.ssl.certificate, &settings.ssl.certificate); - conf.add>("", "ssl.private_key", "private key file (PEM format)", settings.ssl.private_key, &settings.ssl.private_key); + conf.add>("", "ssl.certificate_key", "private key file (PEM format)", settings.ssl.certificate_key, &settings.ssl.certificate_key); conf.add>("", "ssl.key_password", "key password (for encrypted private key)", settings.ssl.key_password, &settings.ssl.key_password); // Users setting