Class SslTransportLayerTest
java.lang.Object
org.apache.kafka.common.network.SslTransportLayerTest
@Tag("bazel:size:large") @Tag("bazel:shard_count:4")
public class SslTransportLayerTest
extends Object
Tests for the SSL transport layer. These use a test harness that runs a simple socket server that echos back responses.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidteardown()voidtestApplicationBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests handling of BUFFER_OVERFLOW during unwrap when application read buffer is smaller than SSL session application buffer size.voidIf the SSL engine ever invokes the matcher with a non-SNIHostNameserver name (it shouldn't, because we register the matcher for type=host_name only), the matcher must still accept the connection — same reasoning as above.voidDirect unit test forSslTransportLayer.CapturingSniMatcher: when the JDK SSL engine callsmatches()with the client's SNIHostName, the matcher must capture the hostname for later read-out and must always returntrue(returning false would abort the handshake withunrecognized_nameand break the SNI-exempt-tenants flow).voidtestClientAuthenticationDisabledNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server accepts connections from a client that does not provide a certificate if client authentication is disabledvoidtestClientAuthenticationDisabledUntrustedProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server accepts connections from a client configured with an untrusted certificate if client authentication is disabledvoidtestClientAuthenticationRequestedNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server accepts connections from a client that does not provide a certificate if client authentication is requested but not requiredvoidtestClientAuthenticationRequestedValidProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server accepts connections from a client configured with a valid certificate if client authentication is requestedvoidtestClientAuthenticationRequiredNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server does not accept connections from clients which don't provide a certificate when client authentication is required.voidtestClientAuthenticationRequiredUntrustedProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server does not accept connections from clients with an untrusted certificate when client authentication is required.voidtestClientAuthenticationRequiredValidProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server accepts connections from clients with a trusted certificate when client authentication is required.voidtestClientEndpointNotValidated(org.apache.kafka.common.network.SslTransportLayerTest.Args args) According to RFC 2818: Typically, the server has no external knowledge of what the client's identity ought to be and so checks (other than that the client has a certificate chain rooted in an appropriate CA) are not possible.voidtestClosePlaintext(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestCloseSsl(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestCustomClientAndServerSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests if client and server both can plugin customize ssl.engine.factory and talk to each other!voidtestCustomClientSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests if client can plugin customize ssl.engine.factoryvoidtestCustomServerSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests if server can plugin customize ssl.engine.factoryvoidtestDsaKeyPair(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests key-pair created using DSA.voidtestECKeyPair(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests key-pair created using EC.voidvoidtestEndpointIdentificationDisabled(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server certificate with invalid host name is accepted by a client that has disabled endpoint validationvoidtestEndpointIdentificationNoReverseLookup(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that hostname verification is performed on the host name or address specified by the client without using reverse DNS lookup.voidtestEngineFactoryDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidvoidtestGracefulRemoteCloseDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that if the remote end closes the connection during SSL handshake while reading data, the disconnection is not treated as an authentication failure.voidtestGracefulRemoteCloseDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that if the remote end closes the connection during SSL handshake while writing data, the disconnection is not treated as an authentication failure.voidtestHandleProxyProtocolBuffer(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidSSLEngine implementations may transition from NEED_UNWRAP to NEED_UNWRAP even after reading all the data from the socket.voidA ClientHello with an internally-inconsistent handshakeLength (smaller than the fixed-size header fields) is malformed, not incomplete.voidPartial-then-full read: the first handshakeUnwrap only has part of the ClientHello, so SNI parsing must defer; the second call sees the rest and must actually parse out the SNI host name.voidMalformed bytes that begin with 0x16 but claim a record length larger than the buffer can hold make parseSniServerName returnOptional.empty()— the "not enough data yet" signal.voidtestInterBrokerSslConfigValidation(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Verifies that inter-broker listener with validation of truststore against keystore works with configs including mutual authentication and hostname verification.voidtestInterBrokerSslConfigValidationFailure(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Verifies that inter-broker listener with validation of truststore against keystore fails if certs from keystore are not trusted.voidtestInvalidEndpointIdentification(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server certificate with invalid host name is not accepted by a client that validates server endpoint.voidtestInvalidKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that client connections cannot be created to a server if key password is invalidvoidtestInvalidKeystorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that channels cannot be created if keystore cannot be loadedvoidtestInvalidSecureRandomImplementation(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that an invalid SecureRandom implementation cannot be configuredvoidtestInvalidSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests invalid ssl.engine.factory plugin classvoidtestInvalidTruststorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that channels cannot be created if truststore cannot be loadedvoidtestIOExceptionsDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that IOExceptions from read during SSL handshake are not treated as authentication failures.voidtestIOExceptionsDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that IOExceptions from write during SSL handshake are not treated as authentication failures.voidtestListenerConfigOverride(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that disabling client authentication as a listener override has the desired effect.voidtestLogMessageForSslHandshakeException(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Verify the log message from the exception thrown when Endpoint validation fails.voidtestNetReadBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests handling of BUFFER_UNDERFLOW during unwrap when network read buffer is smaller than SSL session packet buffer size.voidtestNetworkThreadTimeRecorded(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that time spent on the network thread is accumulated on each channelvoidtestNetWriteBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests handling of BUFFER_OVERFLOW during wrap when network write buffer is smaller than SSL session packet buffer size.voidtestNullTruststorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that client connections can be created to a server if null truststore password is usedvoidtestPeerNotifiedOfHandshakeFailure(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that handshake failures are propagated only after writes complete, even when there are delays in writes to ensure that clients see an authentication exception rather than a connection failure.voidtestPeerNotifiedOfHandshakeFailureWithClientSideDelay(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestPemFiles(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests PEM key store and trust store files which don't have store passwords.voidtestPemFilesWithoutClientKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Test with PEM key store files without key password for client key store.voidtestPemFilesWithoutServerKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Test with PEM key store files without key password for server key store.We don't allow this with PEM files since unprotected private key on disk is not safe.voidtestProxyEngineConsumesFullSocketRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestRequestClientAuthDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests dynamic update of ssl.client.auth configvoidvoidtestSelectorPollReadSize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) selector.poll() should be able to fetch more data than netReadBuffer from the socket.voidtestServerCipherDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestServerKeystoreDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests reconfiguration of server keystore.voidtestServerKeystoreDynamicUpdateWithNewSubjectAltName(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidtestServerRequestMetrics(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidEnd-to-end verification that the JDK SSL engine actually invokes ourSslTransportLayer.CapturingSniMatcherduring a real server-side handshake, and thatSslTransportLayer.sniHostName()returns the value the client sent.voidtestServerSslTransportLayerRejectsNonCompliantSniCleanly(boolean useJdkSniMatcher) INC-377 regression, asserting the matcher path and the legacySslUtilpath behave identically for a non-compliant SNI.voidtestServerTruststoreDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests reconfiguration of server truststore.voidtestSHA1SignedCerts(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Verifies that SHA-1 signed certificates work for backwards compatibilityvoidtestSslEnabledProtocolsDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) voidvoidsuppliedClusterId()derives the tenant cluster id (used in audit / handshake-failure error reporting) purely from the SNI host name returned bySslTransportLayer.sniHostName(), regardless of whether that host name came from the JDK matcher or the legacy parser.voidtestTlsDefaults(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that connection succeeds with the default TLS version.voidtestUngracefulRemoteCloseDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that if the remote end closes connection ungracefully during SSL handshake while reading data, the disconnection is not treated as an authentication failure.voidtestUngracefulRemoteCloseDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that if the remote end closes connection ungracefully during SSL handshake while writing data, the disconnection is not treated as an authentication failure.voidtestUnsupportedCiphers(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that connections cannot be made with unsupported TLS cipher suitesvoidtestValidEndpointIdentificationCN(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server certificate with CN containing valid hostname is accepted by a client that connects using hostname and validates server endpoint.voidtestValidEndpointIdentificationSanDns(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server certificate with SubjectAltName containing the valid hostname is accepted by a client that connects using the hostname and validates server endpoint.voidtestValidEndpointIdentificationSanIp(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that server certificate with SubjectAltName containing valid IP address is accepted by a client that connects using IP address and validates server endpoint.voidtestWithProxyProtocolEngine(org.apache.kafka.common.network.SslTransportLayerTest.Args args)
-
Constructor Details
-
SslTransportLayerTest
public SslTransportLayerTest()
-
-
Method Details
-
teardown
-
testValidEndpointIdentificationSanDns
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testValidEndpointIdentificationSanDns(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server certificate with SubjectAltName containing the valid hostname is accepted by a client that connects using the hostname and validates server endpoint.- Throws:
Exception
-
testValidEndpointIdentificationSanIp
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testValidEndpointIdentificationSanIp(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server certificate with SubjectAltName containing valid IP address is accepted by a client that connects using IP address and validates server endpoint.- Throws:
Exception
-
testValidEndpointIdentificationCN
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testValidEndpointIdentificationCN(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server certificate with CN containing valid hostname is accepted by a client that connects using hostname and validates server endpoint.- Throws:
Exception
-
testEndpointIdentificationNoReverseLookup
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testEndpointIdentificationNoReverseLookup(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that hostname verification is performed on the host name or address specified by the client without using reverse DNS lookup. Certificate is created with hostname, client connection uses IP address. Endpoint validation must fail.- Throws:
Exception
-
testClientEndpointNotValidated
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientEndpointNotValidated(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception According to RFC 2818:Typically, the server has no external knowledge of what the client's identity ought to be and so checks (other than that the client has a certificate chain rooted in an appropriate CA) are not possible. If a server has such knowledge (typically from some source external to HTTP or TLS) it SHOULD check the identity as described above.
However, Java SSL engine does not perform any endpoint validation for client IP address. Hence it is safe to avoid reverse DNS lookup while creating the SSL engine. This test checks that client validation does not fail even if the client certificate has an invalid hostname. This test is to ensure that if client endpoint validation is added to Java in future, we can detect and update Kafka SSL code to enable validation on the server-side and provide hostname if required.- Throws:
Exception
-
testInvalidEndpointIdentification
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidEndpointIdentification(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server certificate with invalid host name is not accepted by a client that validates server endpoint. Server certificate uses wrong hostname as common name to trigger endpoint validation failure.- Throws:
Exception
-
testEndpointIdentificationDisabled
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testEndpointIdentificationDisabled(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server certificate with invalid host name is accepted by a client that has disabled endpoint validation- Throws:
Exception
-
testClientAuthenticationRequiredValidProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationRequiredValidProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server accepts connections from clients with a trusted certificate when client authentication is required.- Throws:
Exception
-
testListenerConfigOverride
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testListenerConfigOverride(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that disabling client authentication as a listener override has the desired effect.- Throws:
Exception
-
testClientAuthenticationRequiredUntrustedProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationRequiredUntrustedProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server does not accept connections from clients with an untrusted certificate when client authentication is required.- Throws:
Exception
-
testClientAuthenticationRequiredNotProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationRequiredNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server does not accept connections from clients which don't provide a certificate when client authentication is required.- Throws:
Exception
-
testClientAuthenticationDisabledUntrustedProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationDisabledUntrustedProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server accepts connections from a client configured with an untrusted certificate if client authentication is disabled- Throws:
Exception
-
testClientAuthenticationDisabledNotProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationDisabledNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server accepts connections from a client that does not provide a certificate if client authentication is disabled- Throws:
Exception
-
testClientAuthenticationRequestedValidProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationRequestedValidProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server accepts connections from a client configured with a valid certificate if client authentication is requested- Throws:
Exception
-
testClientAuthenticationRequestedNotProvided
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testClientAuthenticationRequestedNotProvided(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that server accepts connections from a client that does not provide a certificate if client authentication is requested but not required- Throws:
Exception
-
testSHA1SignedCerts
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testSHA1SignedCerts(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Verifies that SHA-1 signed certificates work for backwards compatibility- Throws:
Exception
-
testDsaKeyPair
-
testECKeyPair
-
testPemFiles
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testPemFiles(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests PEM key store and trust store files which don't have store passwords.- Throws:
Exception
-
testPemFilesWithoutClientKeyPassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testPemFilesWithoutClientKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Test with PEM key store files without key password for client key store.- Throws:
Exception
-
testPemFilesWithoutServerKeyPassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testPemFilesWithoutServerKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Test with PEM key store files without key password for server key store.We don't allow this with PEM files since unprotected private key on disk is not safe.- Throws:
Exception
-
testInvalidSecureRandomImplementation
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidSecureRandomImplementation(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that an invalid SecureRandom implementation cannot be configured -
testInvalidTruststorePassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidTruststorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that channels cannot be created if truststore cannot be loaded -
testInvalidKeystorePassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidKeystorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests that channels cannot be created if keystore cannot be loaded -
testNullTruststorePassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testNullTruststorePassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that client connections can be created to a server if null truststore password is used- Throws:
Exception
-
testInvalidKeyPassword
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidKeyPassword(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that client connections cannot be created to a server if key password is invalid- Throws:
Exception
-
testTlsDefaults
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testTlsDefaults(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that connection succeeds with the default TLS version.- Throws:
Exception
-
testUnsupportedCiphers
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testUnsupportedCiphers(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that connections cannot be made with unsupported TLS cipher suites- Throws:
Exception
-
testServerRequestMetrics
-
testSelectorPollReadSize
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testSelectorPollReadSize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception selector.poll() should be able to fetch more data than netReadBuffer from the socket.- Throws:
Exception
-
testNetReadBufferResize
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testNetReadBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests handling of BUFFER_UNDERFLOW during unwrap when network read buffer is smaller than SSL session packet buffer size.- Throws:
Exception
-
testNetWriteBufferResize
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testNetWriteBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests handling of BUFFER_OVERFLOW during wrap when network write buffer is smaller than SSL session packet buffer size.- Throws:
Exception
-
testApplicationBufferResize
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testApplicationBufferResize(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests handling of BUFFER_OVERFLOW during unwrap when application read buffer is smaller than SSL session application buffer size.- Throws:
Exception
-
testNetworkThreadTimeRecorded
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) @Disabled public void testNetworkThreadTimeRecorded(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that time spent on the network thread is accumulated on each channel- Throws:
Exception
-
testIOExceptionsDuringHandshakeRead
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testIOExceptionsDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that IOExceptions from read during SSL handshake are not treated as authentication failures.- Throws:
Exception
-
testIOExceptionsDuringHandshakeWrite
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testIOExceptionsDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that IOExceptions from write during SSL handshake are not treated as authentication failures.- Throws:
Exception
-
testUngracefulRemoteCloseDuringHandshakeRead
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testUngracefulRemoteCloseDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that if the remote end closes connection ungracefully during SSL handshake while reading data, the disconnection is not treated as an authentication failure.- Throws:
Exception
-
testUngracefulRemoteCloseDuringHandshakeWrite
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testUngracefulRemoteCloseDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that if the remote end closes connection ungracefully during SSL handshake while writing data, the disconnection is not treated as an authentication failure.- Throws:
Exception
-
testGracefulRemoteCloseDuringHandshakeRead
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testGracefulRemoteCloseDuringHandshakeRead(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that if the remote end closes the connection during SSL handshake while reading data, the disconnection is not treated as an authentication failure.- Throws:
Exception
-
testGracefulRemoteCloseDuringHandshakeWrite
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testGracefulRemoteCloseDuringHandshakeWrite(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that if the remote end closes the connection during SSL handshake while writing data, the disconnection is not treated as an authentication failure.- Throws:
Exception
-
testPeerNotifiedOfHandshakeFailure
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testPeerNotifiedOfHandshakeFailure(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests that handshake failures are propagated only after writes complete, even when there are delays in writes to ensure that clients see an authentication exception rather than a connection failure.- Throws:
Exception
-
testPeerNotifiedOfHandshakeFailureWithClientSideDelay
-
testCloseSsl
-
testClosePlaintext
-
testInterBrokerSslConfigValidation
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInterBrokerSslConfigValidation(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Verifies that inter-broker listener with validation of truststore against keystore works with configs including mutual authentication and hostname verification.- Throws:
Exception
-
testInterBrokerSslConfigValidationFailure
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInterBrokerSslConfigValidationFailure(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Verifies that inter-broker listener with validation of truststore against keystore fails if certs from keystore are not trusted. -
testServerKeystoreDynamicUpdate
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testServerKeystoreDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests reconfiguration of server keystore. Verifies that existing connections continue to work with old keystore and new connections work with new keystore.- Throws:
Exception
-
testServerKeystoreDynamicUpdateWithNewSubjectAltName
-
testServerTruststoreDynamicUpdate
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testServerTruststoreDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests reconfiguration of server truststore. Verifies that existing connections continue to work with old truststore and new connections work with new truststore.- Throws:
Exception
-
testServerCipherDynamicUpdate
-
testSslEnabledProtocolsDynamicUpdate
-
testEngineFactoryDynamicUpdate
-
testRequestClientAuthDynamicUpdate
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testRequestClientAuthDynamicUpdate(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests dynamic update of ssl.client.auth config- Throws:
Exception
-
testCustomClientSslEngineFactory
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testCustomClientSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests if client can plugin customize ssl.engine.factory- Throws:
Exception
-
testCustomServerSslEngineFactory
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testCustomServerSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests if server can plugin customize ssl.engine.factory- Throws:
Exception
-
testCustomClientAndServerSslEngineFactory
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testCustomClientAndServerSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Tests if client and server both can plugin customize ssl.engine.factory and talk to each other!- Throws:
Exception
-
testInvalidSslEngineFactory
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testInvalidSslEngineFactory(org.apache.kafka.common.network.SslTransportLayerTest.Args args) Tests invalid ssl.engine.factory plugin class -
testLogMessageForSslHandshakeException
@ParameterizedTest @ArgumentsSource(org.apache.kafka.common.network.SslTransportLayerTest.SslTransportLayerArgumentsProvider.class) public void testLogMessageForSslHandshakeException(org.apache.kafka.common.network.SslTransportLayerTest.Args args) throws Exception Verify the log message from the exception thrown when Endpoint validation fails.- Throws:
Exception
-
testWithProxyProtocolEngine
-
testProxyEngineConsumesFullSocketRead
-
testHandleProxyProtocolBuffer
-
testHandshakeUnwrapContinuesUnwrappingOnNeedUnwrapAfterAllBytesRead
@Test public void testHandshakeUnwrapContinuesUnwrappingOnNeedUnwrapAfterAllBytesRead() throws IOExceptionSSLEngine implementations may transition from NEED_UNWRAP to NEED_UNWRAP even after reading all the data from the socket. This test ensures we continue unwrapping and not break early. Please refer KAFKA-16305 for more information.- Throws:
IOException
-
testSSLEngineCloseInboundInvokedOnClose
- Throws:
IOException
-
testGatheringWrite
@Test @Disabled("This test needs to be fixed for ce-kafka") public void testGatheringWrite() throws IOException- Throws:
IOException
-
testScatteringRead
- Throws:
IOException
-
testEnableIpFiltering
@Test public void testEnableIpFiltering() -
testCapturingSniMatcherCapturesHostNameAndAccepts
@Test public void testCapturingSniMatcherCapturesHostNameAndAccepts()Direct unit test forSslTransportLayer.CapturingSniMatcher: when the JDK SSL engine callsmatches()with the client's SNIHostName, the matcher must capture the hostname for later read-out and must always returntrue(returning false would abort the handshake withunrecognized_nameand break the SNI-exempt-tenants flow). -
testCapturingSniMatcherAcceptsNonHostNameServerNameWithoutCapturing
@Test public void testCapturingSniMatcherAcceptsNonHostNameServerNameWithoutCapturing()If the SSL engine ever invokes the matcher with a non-SNIHostNameserver name (it shouldn't, because we register the matcher for type=host_name only), the matcher must still accept the connection — same reasoning as above. We just don't capture anything in that case. -
testServerSslTransportLayerRejectsNonCompliantSniCleanly
@ParameterizedTest @ValueSource(booleans={true,false}) public void testServerSslTransportLayerRejectsNonCompliantSniCleanly(boolean useJdkSniMatcher) throws Exception INC-377 regression, asserting the matcher path and the legacySslUtilpath behave identically for a non-compliant SNI. A clienthost_namewith non-LDH characters (e.g. an underscore) is rejected by the JDK engine itself during ClientHello processing — with a checked— regardless of which SNI extraction path is configured, because the engine's extension decoder (not our matcher or parser) is what rejects it. So switching to the JDK matcher does not change the behaviour: the malformed SNI still fails the handshake cleanly with a checkedinvalid reference
SSLProtocolExceptionSSLException, never letting an unchecked exception escape the handshake path the way the originalSslUtilparser did. Nothing is captured in either mode.SNIHostName's own constructor rejects non-LDH names, so we put a raw server name of typehost_nameon the wire to reproduce what a non-compliant client actually sends.- Throws:
Exception
-
testSuppliedClusterIdExtractedFromSniHostName
@Test public void testSuppliedClusterIdExtractedFromSniHostName()suppliedClusterId()derives the tenant cluster id (used in audit / handshake-failure error reporting) purely from the SNI host name returned bySslTransportLayer.sniHostName(), regardless of whether that host name came from the JDK matcher or the legacy parser. It must extractlkc-<id>from an lkc-prefixed host name and return empty for anything else. -
testHandshakeUnwrapTreatsBufferUnderflowAsTransient
Malformed bytes that begin with 0x16 but claim a record length larger than the buffer can hold make parseSniServerName returnOptional.empty()— the "not enough data yet" signal. It must not crash handshakeUnwrap and must not be latched as a permanent parse failure (more bytes might still arrive).- Throws:
IOException
-
testHandshakeUnwrapLatchesPermanentSniParseFailureOnMalformedClientHello
@Test public void testHandshakeUnwrapLatchesPermanentSniParseFailureOnMalformedClientHello() throws IOExceptionA ClientHello with an internally-inconsistent handshakeLength (smaller than the fixed-size header fields) is malformed, not incomplete. parseSniServerName converts this into an SSLProtocolException via parseHandshake's catch, which parseSNIHostNameIfPresent then latches as a permanent failure so downstream rejection (KafkaChannel#sniHostNameIsValid) can fail the connection cleanly.- Throws:
IOException
-
testHandshakeUnwrapRetriesSniParseAcrossPartialReads
Partial-then-full read: the first handshakeUnwrap only has part of the ClientHello, so SNI parsing must defer; the second call sees the rest and must actually parse out the SNI host name. This exercises the retry path: limit-bounding the buffer to received bytes, not latching sniParsingFailed on an empty Optional, and not single-shot-clearing shouldParseSNI after the first attempt.- Throws:
IOException
-
testServerSslTransportLayerCapturesSniDuringRealHandshake
@ParameterizedTest @ValueSource(strings={"TLSv1.2","TLSv1.3"}) public void testServerSslTransportLayerCapturesSniDuringRealHandshake(String tlsProtocol) throws Exception End-to-end verification that the JDK SSL engine actually invokes ourSslTransportLayer.CapturingSniMatcherduring a real server-side handshake, and thatSslTransportLayer.sniHostName()returns the value the client sent. Builds a matched client/server pair of realSSLEngines via the productionSslFactory, constructs the serverSslTransportLayerthrough the same constructor used in production (soinstallSniMatcherIfNeededruns), drives the handshake in-memory until completion, and asserts capture.Parameterized over TLS 1.2 and 1.3 — TLS 1.3 specifically is the version that triggered INC-10922 because its larger and immediately-sent ClientHello widened the partial-read race window that exposed the bug in the old custom parser. Both versions must capture SNI correctly through the new matcher path.
- Throws:
Exception
-