Skip to content

feat: Add MongoDB TLS CA certificate support via lib-commons #87

@ferr3ira-gabriel

Description

@ferr3ira-gabriel

Summary

Matcher does not support loading TLS CA certificates for MongoDB connections, which is required for secure connections to AWS DocumentDB.

Current State

Matcher uses direct MongoDB connection without any TLS configuration. This prevents secure connections to managed MongoDB services like AWS DocumentDB that require CA certificate validation.

Proposed Solution

Migrate MongoDB connection to use lib-commons/v4/commons/mongo and add support for MONGO_TLS_CA_CERT env var (base64 encoded PEM):

var tlsCfg *libMongo.TLSConfig
if cfg.MongoTLSCACert != "" {
    tlsCfg = &libMongo.TLSConfig{CACertBase64: cfg.MongoTLSCACert}
}

mongoConnection, err := libMongo.NewClient(ctx, libMongo.Config{
    URI:      mongoSource,
    Database: cfg.MongoDBName,
    TLS:      tlsCfg,
})

This follows the same pattern used for Redis: REDIS_CA_CERTlibRedis.TLSConfig{CACertBase64}

Why

AWS DocumentDB requires TLS with a specific CA certificate. Currently the only workaround is tlsInsecure=true which skips certificate validation - not ideal for production.

Acceptance Criteria

  • Migrate MongoDB connection to lib-commons/mongo
  • Add MONGO_TLS_CA_CERT env var to config struct
  • Pass TLS config to lib-commons/mongo NewClient
  • Update helm chart to support the new env var

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