Skip to content

Improve logging around connection establishment #407

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

Merged
merged 1 commit into from
Sep 27, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,17 @@ public void start()
{
try
{
logger.debug( "~~ [CONNECT] %s", address );
logger.debug( "Connecting to %s, secure: %s", address, securityPlan.requiresEncryption() );
if( channel == null )
{
setChannel( ChannelFactory.create( address, securityPlan, timeoutMillis, logger ) );
logger.debug( "Connected to %s, secure: %s", address, securityPlan.requiresEncryption() );
}
setProtocol( negotiateProtocol() );

logger.debug( "Negotiating protocol with %s", address );
SocketProtocol protocol = negotiateProtocol();
setProtocol( protocol );
logger.debug( "Selected protocol %s with %s", protocol.getClass(), address );
}
catch ( ConnectException e )
{
Expand Down Expand Up @@ -206,7 +211,7 @@ public void stop()
{
channel.close();
setChannel( null );
logger.debug( "~~ [DISCONNECT]" );
logger.debug( "Disconnected from %s", address );
}
}
catch ( IOException e )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public static TLSSocketChannel create( ByteChannel channel, Logger logger, SSLEn
*/
private void runHandshake() throws IOException
{
logger.debug( "~~ [OPENING SECURE CHANNEL]" );
logger.debug( "Running TLS handshake" );

sslEngine.beginHandshake();
HandshakeStatus handshakeStatus = sslEngine.getHandshakeStatus();
while ( handshakeStatus != FINISHED && handshakeStatus != NOT_HANDSHAKING )
Expand All @@ -142,6 +143,8 @@ private void runHandshake() throws IOException
break;
}
}

logger.debug( "TLS handshake completed" );
}

private HandshakeStatus runDelegatedTasks()
Expand Down Expand Up @@ -479,7 +482,7 @@ public void close() throws IOException
}
// Close transport
channel.close();
logger.debug( "~~ [CLOSED SECURE CHANNEL]" );
logger.debug( "Closed secure channel" );
}
catch ( IOException e )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void shouldPerformTLSHandshakeWithTrustedCert() throws Throwable
sslChannel.close();

// Then
verify( logger, atLeastOnce() ).debug( "~~ [OPENING SECURE CHANNEL]" );
verify( logger, atLeastOnce() ).debug( "Running TLS handshake" );
}
finally
{
Expand Down Expand Up @@ -290,7 +290,7 @@ public void shouldPerformTLSHandshakeWithTheSameTrustedServerCert() throws Throw
sslChannel.close();

// Then
verify( logger, atLeastOnce() ).debug( "~~ [OPENING SECURE CHANNEL]" );
verify( logger, atLeastOnce() ).debug( "Running TLS handshake" );
}

@Test
Expand Down Expand Up @@ -357,7 +357,7 @@ private void performTLSHandshakeUsingKnownCerts( File knownCerts ) throws Throwa
sslChannel.close();

// Then
verify( logger, atLeastOnce() ).debug( "~~ [CLOSED SECURE CHANNEL]" );
verify( logger, atLeastOnce() ).debug( "Closed secure channel" );
}

private File installRootCertificate() throws Exception
Expand Down