Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SecureSocketPort: Enable Server Name Indication (SNI) by default #1456

Merged
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
9 changes: 9 additions & 0 deletions Source/core/NodeId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ namespace Core {
const uint16_t nPortNumber,
const enumType defaultType)
: m_hostName()
, m_remoteHostName(strHostName)
{

m_structInfo.IPV4Socket.sin_family = TYPE_UNSPECIFIED;
Expand All @@ -241,6 +242,7 @@ namespace Core {
const TCHAR strHostName[],
const enumType defaultType)
: m_hostName()
, m_remoteHostName(strHostName)
{

m_structInfo.IPV4Socket.sin_family = TYPE_UNSPECIFIED;
Expand Down Expand Up @@ -368,6 +370,7 @@ namespace Core {
memcpy(&m_structInfo, &rInfo.m_structInfo, sizeof(m_structInfo));

m_hostName = rInfo.m_hostName;
m_remoteHostName = rInfo.m_remoteHostName;

// Give back our-selves.
return (*this);
Expand Down Expand Up @@ -556,6 +559,12 @@ namespace Core {
return (m_hostName);
}

string
NodeId::RemoteHostName() const
{
return (m_remoteHostName);
}

void NodeId::HostName(const TCHAR strHostName[])
{
}
Expand Down
2 changes: 2 additions & 0 deletions Source/core/NodeId.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ namespace Core {
}

string HostName() const;
string RemoteHostName() const;
void HostName(const TCHAR strHostName[]);

NodeId AnyInterface() const;
Expand Down Expand Up @@ -285,6 +286,7 @@ namespace Core {
}

mutable string m_hostName;
string m_remoteHostName;
SocketInfo m_structInfo;
static bool m_isIPV6Enabled;
};
Expand Down
7 changes: 7 additions & 0 deletions Source/cryptalgo/SecureSocketPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ bool SecureSocketPort::Handler::Initialize() {
_ssl = SSL_new(static_cast<SSL_CTX*>(_context));
SSL_set_fd(static_cast<SSL*>(_ssl), static_cast<Core::IResource&>(*this).Descriptor());

// Enable SNI by default (Server Name Indication) in case there's a host name set in the remote
// node, so that the TLS "Client Hello" message contains a "server_name" extension with the host
// name, this way allowing a better interoperability with TLS servers.
if (!RemoteNode().RemoteHostName().empty()) {
SSL_set_tlsext_host_name(static_cast<SSL*>(_ssl), RemoteNode().RemoteHostName().c_str());
}

return (Core::SocketPort::Initialize());
}

Expand Down
Loading