Fix : Compilation issue when ssl is disabled
- When the SSL is disabled, the socket that bmcweb uses would be
a basic_socket type , and that does not have a next_layer as that
itself is the basic socket, we can directly read the socket object/
or use the lowest_layer() of the socket to get the ip address from it.
- When SSL is enabled, the socket that bmcweb uses would be an ssl
stream over basic_socket, and here the next_layer would be basic_socket,
so the existing logic holds good.
- The idea behind this commit is to , have a conditional check for SSL
vs non-SSL configurations before reading the socket for ip address.
Tested By:
* cmake -DBMCWEB_INSECURE_DISABLE_SSL=1 -DCMAKE_BUILD_TYPE:type=Debug ../ ; make
- The above Compilation was successfull.
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I2b9a127be30b11b056641342e0af06118c526528
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 1ec2303..8080e6f 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -227,8 +227,13 @@
}
}
#endif
+
+#ifdef BMCWEB_ENABLE_SSL
clientIp =
req.socket().next_layer().remote_endpoint().address().to_string();
+#else
+ clientIp = req.socket().remote_endpoint().address().to_string();
+#endif
// User is authenticated - create session
std::shared_ptr<crow::persistent_data::UserSession> session =