-
Notifications
You must be signed in to change notification settings - Fork 912
Open
Description
I would like to be able to connect to couchbase using a CA cert or be able to specify InsecureSkip (for local testing)
The needs to have SecurityConfig: gocb.SecurityConfig added. Below is some test code I made that uses the couchbase sdk to support these needs.
// Load CA certificate if available
var tlsConfig *tls.Config
if _, err := os.Stat(certPath); err == nil {
caCert, err := os.ReadFile(certPath)
if err != nil {
log.Printf("Warning: Failed to read CA certificate: %v", err)
} else {
caCertPool := x509.NewCertPool()
if caCertPool.AppendCertsFromPEM(caCert) {
tlsConfig = &tls.Config{
RootCAs: caCertPool,
}
fmt.Println("Loaded CA certificate")
}
}
}
// If no cert loaded, skip TLS verification
if tlsConfig == nil {
tlsConfig = &tls.Config{
InsecureSkipVerify: true,
}
fmt.Println("Using InsecureSkipVerify for TLS")
}
// Connect to cluster
cluster, err := gocb.Connect(connectionString, gocb.ClusterOptions{
Authenticator: gocb.PasswordAuthenticator{
Username: username,
Password: password,
},
SecurityConfig: gocb.SecurityConfig{
TLSRootCAs: tlsConfig.RootCAs,
TLSSkipVerify: tlsConfig.InsecureSkipVerify,
},
})
Metadata
Metadata
Assignees
Labels
No labels