# WithTlsAllowInvalidCertificates

- Module: [Aspire.Hosting.MongoDB](/reference/api/go/aspire.hosting.mongodb.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`MongoDBServerResource`](/reference/api/go/aspire.hosting.mongodb/mongodbserverresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/2d325b13709752ba6d9a943635c5e2940a2530c0)

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
func (MongoDBServerResource) WithTlsAllowInvalidCertificates() MongoDBServerResource
```

## Returns

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

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

## Applies to

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