diff options
author | Abhilash Raju <abhilash.kollam@gmail.com> | 2024-06-03 19:40:17 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-06-10 18:18:59 +0300 |
commit | d5fb584a8ad7d493a3236261f727852f262271c6 (patch) | |
tree | 4263838834bbfc9f595610d44ea82ea8140542d0 /http/http_server.hpp | |
parent | 099225cc9300c8e06b742a48318df75b0366561f (diff) | |
download | bmcweb-d5fb584a8ad7d493a3236261f727852f262271c6.tar.xz |
MTLS Client: Enabling mtls support in http_client
http_client currently does not uses mtls client certificates. This is
a good feature for both authentication and authorization purpose.
It will help external servers to trust the identity of bmc for better
security.This patch will add MTLS client certificate support for bmcweb
This is a needed feature to support secure redfish aggregation between
BMCs.
To support secure aggregation BMCs should be provisioned with CA signed
certificate with an authorized username as the subject name field of the
certificate.
With the support of strong MTLS authentication from Bmcweb server we can
use the MTLS path to enable secure redfish aggregation among BMCs. This
can avoid complexities and extra API calls needed for token based
approach.
Tested by:
Aggregation Test1:
1) Setup two instance of romulus qemu session at different ports.This
will act as two BMCs
2) Installed CA root certificates at /etc/ssl/certs/authority in both
BMCs
3) Installed server.pem and client.pem entity certificates signed by the
root CA at /etc/ssl/certs/https folder in both BMCs
4) Enable aggregation for Bmcweb.
5) Fired several redfish queries to BMC1
Result
Observed that the aggregation worked fine. User session created using
username mentined in the CN field of certificate.
Aggregation Test2:
Followed same steps from Aggregation Test1 with modification in step 3
In step3 installed only the server.pem.
Result
Bmcweb ran as usual. But aggregation failed to collect resources from
BMC2. No crash observed.
Redfish Event Test:
Subscribed for redfish events using test server.
Fired redfish test events from BMC.
Result:
Events reached server successfully.
Change-Id: Id8cccf9beec77da0f16adb72d52f3adf46347d06
Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Diffstat (limited to 'http/http_server.hpp')
-rw-r--r-- | http/http_server.hpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/http/http_server.hpp b/http/http_server.hpp index 6088ca1a2e..6d725c9c0a 100644 --- a/http/http_server.hpp +++ b/http/http_server.hpp @@ -79,37 +79,9 @@ class Server { return; } - namespace fs = std::filesystem; - // Cleanup older certificate file existing in the system - fs::path oldCert = "/home/root/server.pem"; - if (fs::exists(oldCert)) - { - fs::remove("/home/root/server.pem"); - } - fs::path certPath = "/etc/ssl/certs/https/"; - // if path does not exist create the path so that - // self signed certificate can be created in the - // path - if (!fs::exists(certPath)) - { - fs::create_directories(certPath); - } - fs::path certFile = certPath / "server.pem"; - BMCWEB_LOG_INFO("Building SSL Context file={}", certFile.string()); - std::string sslPemFile(certFile); - std::string cert = - ensuressl::ensureOpensslKeyPresentAndValid(sslPemFile); - if (cert.empty()) - { - throw std::runtime_error("Failed to load string"); - } - std::shared_ptr<boost::asio::ssl::context> sslContext = - ensuressl::getSslContext(cert); - if (sslContext == nullptr) - { - throw std::runtime_error("Failed to load certificate"); - } - BMCWEB_LOG_DEBUG("Replaced certificate"); + + auto sslContext = ensuressl::getSslServerContext(); + adaptorCtx = sslContext; handler->ssl(std::move(sslContext)); } @@ -167,7 +139,7 @@ class Server if (adaptorCtx == nullptr) { BMCWEB_LOG_CRITICAL( - "Asked to lauch TLS socket but no context available"); + "Asked to launch TLS socket but no context available"); return; } connection = std::make_shared<Connection<Adaptor, Handler>>( |