Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions http/http_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,19 @@ class ConnectionInfo : public std::enable_shared_from_this<ConnectionInfo>
return;
}
sslConn.emplace(conn, *sslCtx);
// set SNI hostname
if (!SSL_set_tlsext_host_name(sslConn->native_handle(),
kMtlsSniHostname))
{
BMCWEB_LOG_ERROR("Failed to set SNI hostname");
// Continue - server to detect the mtls connection
}
else
{
BMCWEB_LOG_DEBUG(
"Successfully set SNI to {} for mTLS aggregation",
kMtlsSniHostname);
}
setCipherSuiteTLSext();
}
}
Expand Down
11 changes: 11 additions & 0 deletions include/ssl_key_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@
#include <memory>
#include <optional>
#include <string>
// Common SNI hostname for mTLS
constexpr const char* kMtlsSniHostname = "mtls.bmc";

// SNI parsing macros
#define SNI_OFFSET_SIZE 2
#define SNI_NAME_TYPE_SIZE 1
#define SNI_PARSE_START_POS (SNI_OFFSET_SIZE + SNI_NAME_TYPE_SIZE)
#define SNI_GET_HOST_LENGTH(sni, pos) \
(((uint16_t)(sni)[(pos)] << 8) | (sni)[(pos) + 1])
#define SNI_HOST_START_POS(pos) ((pos) + SNI_OFFSET_SIZE)
#define SNI_MIN_LENGTH 5

namespace ensuressl
{
Expand Down
Loading