Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ba9ac99
Added SSL Option
MitulShah1 May 1, 2025
a87e16b
Passed tests
MitulShah1 May 2, 2025
d7c7be5
Implemented SSL Support
MitulShah1 May 2, 2025
22c2887
Implemented SSL Support
MitulShah1 May 2, 2025
dfe89e6
Implemented SSL Support
MitulShah1 May 2, 2025
59a1733
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 May 2, 2025
4e7b372
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 May 2, 2025
875e63f
Merge remote-tracking branch 'origin/add-ssl-option-cassandra' into a…
MitulShah1 May 2, 2025
8e1b349
Revert go.mod and go.sum
MitulShah1 May 2, 2025
26a38e1
Revert go.mod and go.sum
MitulShah1 May 2, 2025
7d76d50
Golint fix
MitulShah1 May 2, 2025
cc1dd06
Golint fix
MitulShah1 May 2, 2025
71100a9
Govet fix
MitulShah1 May 2, 2025
f07aea2
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 May 6, 2025
ac19eb4
reduce wait time, revert container place and removed WithTLS options
MitulShah1 May 7, 2025
5b636f7
Added SSL With option
MitulShah1 May 7, 2025
2ad9f7b
Merge branch 'main' into add-ssl-option-cassandra
May 7, 2025
7409635
Added SSL With option
MitulShah1 May 7, 2025
4c2e3dc
Devide Run function n sub function to reduce complexity
MitulShah1 May 7, 2025
6da1e1e
make Options private
MitulShah1 May 7, 2025
9a4f4f2
removed setupTls function and moved to WithSSL Options
MitulShah1 May 7, 2025
5242c32
Fix Sec warning InsecureSkipVerify
MitulShah1 May 7, 2025
18214a0
Fix lint
MitulShah1 May 7, 2025
8ba3319
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 May 9, 2025
60622d4
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 May 9, 2025
38320ac
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 Jun 3, 2025
d1724a5
Merge branch 'main' into add-ssl-option-cassandra
mdelapenya Jul 18, 2025
b05ef84
Merge branch 'testcontainers:main' into add-ssl-option-cassandra
MitulShah1 Aug 5, 2025
86f661b
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 Oct 14, 2025
879e285
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 Dec 5, 2025
fd5772d
added cassandra ssl option
MitulShah1 Dec 5, 2025
545a00e
removed InsecureSkipVerify variable
MitulShah1 Dec 5, 2025
19f4879
Merge branch 'main' into add-ssl-option-cassandra
MitulShah1 Dec 8, 2025
50579f9
added mising docs and modify TlsConfig method
MitulShah1 Dec 8, 2025
42f32ec
doc changes
MitulShah1 Dec 12, 2025
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
17 changes: 17 additions & 0 deletions docs/modules/cassandra.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ In the case you have a custom config file for Cassandra, it's possible to copy t
!!!warning
You should provide a valid Cassandra configuration file, otherwise the container will fail to start.

#### WithTLS

- Not available until the next release <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>

If you need to enable TLS/SSL encryption for client connections, you can use the `cassandra.WithTLS()` option.

When enabled, the container will:
- Generate self-signed certificates automatically
- Configure Cassandra to use client encryption
- Expose the SSL port (9142)

Use the `TLSConfig()` method on the returned container to get the `*tls.Config` for client connections. The method returns an error if TLS was not enabled via `WithTLS()`.

<!--codeinclude-->
[Using TLS option](../../modules/cassandra/cassandra_test.go) inside_block:withTLS
<!--/codeinclude-->

{% include "../features/common_functional_options_list.md" %}

### Container Methods
Expand Down
10 changes: 7 additions & 3 deletions modules/cassandra/cassandra.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"crypto/tls"
_ "embed"
"errors"
"fmt"
"io"
"path/filepath"
Expand Down Expand Up @@ -38,9 +39,12 @@ func (c *CassandraContainer) ConnectionHost(ctx context.Context) (string, error)
}

// TLSConfig returns the TLS configuration for secure client connections.
// Returns nil if TLS is not enabled on the container.
func (c *CassandraContainer) TLSConfig() *tls.Config {
return c.settings.tlsConfig
// Returns an error if TLS is not enabled on the container.
func (c *CassandraContainer) TLSConfig() (*tls.Config, error) {
if !c.settings.tlsEnabled {
return nil, errors.New("TLS is not enabled on this container")
}
return c.settings.tlsConfig, nil
}

// WithConfigFile sets the YAML config file to be used for the cassandra container
Expand Down
3 changes: 2 additions & 1 deletion modules/cassandra/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ func TestCassandraWithTLS(t *testing.T) {
require.NoError(t, err)

// Verify TLS config is available
tlsConfig := ctr.TLSConfig()
tlsConfig, err := ctr.TLSConfig()
require.NoError(t, err)
require.NotNil(t, tlsConfig, "TLSConfig should not be nil when TLS is enabled")

// Get SSL connection host
Expand Down
6 changes: 5 additions & 1 deletion modules/cassandra/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ func ExampleRun_withTLS() {
}

// Get TLS config for secure connection
tlsConfig := cassandraContainer.TLSConfig()
tlsConfig, err := cassandraContainer.TLSConfig()
if err != nil {
log.Printf("failed to get TLS config: %s", err)
return
}
// }

cluster := gocql.NewCluster(connectionHost)
Expand Down
Loading