Skip to content

Commit

Permalink
OF-2738: Include SNI when setting up outbound server-to-server connec…
Browse files Browse the repository at this point in the history
…tion

When setting up an outbound server-to-server connection, Openfire should send along an indication to what domain name it is attempting to connect. This will help the recipient server to process the connection for the correct vhost when that server is hosting multipe XMPP domains on the same server (ejabberd allows for this, for example).
  • Loading branch information
guusdk authored and Fishbowler committed Nov 17, 2023
1 parent 271731d commit e8f83e8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,19 @@ public void startTLS(boolean clientMode, boolean directTLS) throws Exception {

final EncryptionArtifactFactory factory = new EncryptionArtifactFactory( configuration );

final SslContext sslContext;
final SslHandler sslHandler;
if (clientMode) {
sslContext = factory.createClientModeSslContext();
final SslContext sslContext = factory.createClientModeSslContext();

// OF-2738: Send along the XMPP domain that's needed for SNI
final NettyOutboundConnectionHandler handler = channelHandlerContext.channel().pipeline().get(NettyOutboundConnectionHandler.class);

sslHandler = sslContext.newHandler(channelHandlerContext.alloc(), handler.getDomainPair().getRemote(), handler.getPort());
} else {
sslContext = factory.createServerModeSslContext(directTLS);
final SslContext sslContext = factory.createServerModeSslContext(directTLS);
sslHandler = sslContext.newHandler(channelHandlerContext.alloc());
}

final SslHandler sslHandler = sslContext.newHandler(channelHandlerContext.alloc());
channelHandlerContext.pipeline().addFirst(SSL_HANDLER_NAME, sslHandler);

if ( !clientMode && !directTLS ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ private boolean connectionConfigDoesNotRequireTls() {
return this.configuration.getTlsPolicy() != Connection.TLSPolicy.required;
}

public DomainPair getDomainPair()
{
return domainPair;
}

public int getPort()
{
return port;
}

@Override
public String toString()
{
Expand Down

0 comments on commit e8f83e8

Please sign in to comment.