# MongoDBServerResource.WithTlsAllowInvalidCertificates

- Module: [Aspire.Hosting.MongoDB](/reference/api/go/aspire.hosting.mongodb.md)
- Defined on: [MongoDBServerResource](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource.md)
- Version: `17.0.0`
- Kind: `method`

Configures the MongoDB server to accept TLS connections whose peer certificate cannot be validated, by passing `--tlsAllowInvalidCertificates` to `mongod`.

## Remarks

This weakens certificate authentication and should only be used when a peer legitimately cannot present a
certificate this server is able to validate. It is what
`WithMember`
uses today, because replica set members authenticate to each other with the same certificate they serve to clients
and that certificate does not carry a `clientAuth` extended key usage.
See https://www.mongodb.com/docs/manual/reference/program/mongod/#std-option-mongod.--tlsAllowInvalidCertificates
```
var mongo = builder.AddMongoDB("mongo")
.WithTlsAllowInvalidCertificates();
```

## Definition

```go
type MongoDBServerResource interface {
    // ... omitted for brevity
    WithTlsAllowInvalidCertificates() MongoDBServerResource
}
```

## Signature

```go
WithTlsAllowInvalidCertificates() MongoDBServerResource
```

## Returns

[`MongoDBServerResource`](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [MongoDBServerResource](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource.md) -- `handle`
