Skip to content

Couchbase Options not supported #3919

@kmcrawford

Description

@kmcrawford

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions