# WithCertificateTrustScope

- Module: [Aspire.Hosting](/reference/api/go/aspire.hosting.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: [`ResourceWithEnvironment`](/reference/api/go/aspire.hosting/resourcewithenvironment.md)
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Sets the certificate trust scope

## Remarks

The default scope if not overridden is `Append` which means that custom certificate
authorities should be appended to the default trusted certificate authorities for the resource. Setting the scope to
`Override` indicates the set of certificates in referenced
`CertificateAuthorityCollection` (and optionally Aspire developer certificiates) should be used as the
exclusive source of trust for a resource.
In all cases, this is a best effort implementation as not all resources support full customization of certificate
trust.
Set the scope for custom certificate authorities to override the default trusted certificate authorities for a container resource.
```
var caCollection = builder.AddCertificateAuthorityCollection("my-cas")
.WithCertificate(new X509Certificate2("my-ca.pem"));
var container = builder.AddContainer("my-service", "my-service:latest")
.WithCertificateAuthorityCollection(caCollection)
.WithCertificateTrustScope(CertificateTrustScope.Override);
```

## Definition

```go
func (ResourceWithEnvironment) WithCertificateTrustScope(scope CertificateTrustScope) ResourceWithEnvironment
```

## Parameters

- `scope` ([`CertificateTrustScope`](/reference/api/go/aspire.hosting/certificatetrustscope.md)) -- The scope to apply to custom certificate authorities associated with the resource.

## Returns

[`ResourceWithEnvironment`](/reference/api/go/aspire.hosting/resourcewithenvironment.md) -- The resource builder.

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

## Applies to

- [`CSharpAppResource`](/reference/api/go/aspire.hosting/csharpappresource.md)
- [`ContainerResource`](/reference/api/go/aspire.hosting/containerresource.md)
- [`DotnetToolResource`](/reference/api/go/aspire.hosting/dotnettoolresource.md)
- [`ExecutableResource`](/reference/api/go/aspire.hosting/executableresource.md)
- [`ProjectResource`](/reference/api/go/aspire.hosting/projectresource.md)
