Skip to navigation

Connect to offline environments

Configure the Lattice SDK to connect at the edge

By default, the Lattice SDK validates TLS certificates against your operating system’s trusted Certificate Authority (CA) store.

When your Lattice environment is offline or air-gapped, it’s deployed on a local network without access to a public CA infrastructure. The environment presents a certificate signed by a private Anduril CA that isn’t in your system’s trust store, so your SDK client can’t validate it and the connection fails.

This guide describes two ways to connect:

  1. Use an Anduril-issued certificate: This method lets the SDK trust your environment while keeping full TLS verification enabled. This is the recommended approach in production.
  2. Skip TLS verification with self-signed certificates: This method lets you connect when an Anduril representative can’t issue a certificate. Use this approach only in development environments.

Before you begin

  • Complete the steps in Install to create your project and its reusable client, and to set the LATTICE_ENDPOINT, ENVIRONMENT_TOKEN, and SANDBOXES_TOKEN environment variables. The examples on this page start from that client and change only how it handles TLS.
gRPC authentication

These gRPC examples authenticate with a static environment token attached as request metadata. If you are using OAuth 2.0 client credentials instead, set up the token refresh module before running the examples on this page.

Use an Anduril-issued certificate

This is the recommended approach because it keeps full TLS verification enabled. You obtain a CA certificate from Anduril, add it to your trust store, and configure the SDK to trust it as a root CA. The SDK still validates the certificate chain, hostname, and expiry date.

To obtain the certificate, add it to your trust store, and configure the SDK to trust it, follow these steps:

1

Get the Anduril-issued certificate

Contact your Anduril representative to obtain the CA certificate for your Lattice environment. The certificate is delivered as a PEM-encoded file. Because delivery mechanisms vary, follow the instructions your Anduril representative provides to retrieve it.

2

Add the certificate to the system's trust store

Add the certificate to your operating system’s trust store so that clients on your machine trust it:

sudo security add-trusted-cert -d -r trustRoot \
-k /Library/Keychains/System.keychain /path/to/anduril-ca.pem
3

Set an environment variable with the certificate path

Set a LATTICE_CA_CERT_PATH environment variable that points to the certificate file. The examples in the following steps load the CA certificate from LATTICE_CA_CERT_PATH and configure the Lattice client to trust it as a root CA:

export LATTICE_CA_CERT_PATH=/path/to/anduril-ca.pem
4

Apply the certificate to the common client

Take the client from your project’s common module, and give it an HTTP or gRPC client that trusts the Anduril-issued certificate. Each example loads the certificate from the PEM file at LATTICE_CA_CERT_PATH and adds it to the trust pool, so the client verifies the server’s certificate against the Anduril CA during every TLS handshake. If LATTICE_CA_CERT_PATH isn’t set, the client keeps using your system’s trust store. The example then uses the client to fetch an entity with GetEntity:

package main
import (
"context"
"crypto/tls"
"crypto/x509"
"fmt"
"net/http"
"os"
Lattice "github.com/anduril/lattice-sdk-go/v5"
"github.com/anduril/lattice-sdk-go/v5/client"
"github.com/anduril/lattice-sdk-go/v5/option"
"my-lattice-app/common"
)
func main() {
// Path to the Anduril-issued CA certificate in PEM format
caCertPath := os.Getenv("LATTICE_CA_CERT_PATH")
LatticeClient, err := createLatticeClient(caCertPath)
if err != nil {
fmt.Printf("Error creating Lattice client: %v\n", err)
os.Exit(1)
}
// Use the client
ctx := context.Background()
entity, err := LatticeClient.Entities.GetEntity(
ctx,
&Lattice.GetEntityRequest{
EntityID: "Demo-Sim-Asset1",
},
)
if err != nil {
fmt.Printf("Error fetching entity: %v\n", err)
} else {
fmt.Printf("Asset name | %s\n", *entity.GetAliases().GetName())
fmt.Printf("Asset location | %f, %f\n", *entity.GetLocation().GetPosition().GetLatitudeDegrees(),
*entity.GetLocation().GetPosition().GetLongitudeDegrees())
}
}
func createLatticeClient(caCertPath string) (*client.Client, error) {
// Load the Anduril-issued CA certificate and add it to the trust pool
certPool, err := x509.SystemCertPool()
if err != nil {
certPool = x509.NewCertPool()
}
if caCertPath != "" {
pemBytes, err := os.ReadFile(caCertPath)
if err != nil {
return nil, fmt.Errorf("reading CA certificate: %w", err)
}
if !certPool.AppendCertsFromPEM(pemBytes) {
return nil, fmt.Errorf("failed to append CA certificate from %s", caCertPath)
}
}
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,
},
},
}
// Take the client from my-lattice-app/common and make it trust the CA certificate.
return common.Connect(option.WithHTTPClient(httpClient)), nil
}

After you add the CA certificate to your trust store and load it in your client, your integration can connect to an offline environment with full TLS verification enabled.

Skip TLS verification with self-signed certificates

If you can’t obtain an Anduril-issued certificate for a development environment, you can configure the SDK to skip TLS verification. The SDK then connects without validating the server’s certificate.

Skipping TLS verification disables certificate validation, which exposes your connection to interception and tampering. Use this approach only in development environments where an Anduril representative can’t issue an Anduril-issued certificate. In production, use an Anduril-issued certificate instead.

To skip TLS verification and configure your client, follow these steps:

1

Set an environment variable

Set a SKIP_TLS_VERIFY environment variable so the client knows to skip certificate validation. The examples in the following steps read SKIP_TLS_VERIFY and configure a custom Lattice client that skips TLS verification:

export SKIP_TLS_VERIFY=true
2

Skip TLS verification in the common client

Take the client from your project’s common module, and give it an HTTP or gRPC client that skips certificate validation when SKIP_TLS_VERIFY is true. In Go, this uses the InsecureSkipVerify option; the other languages provide an equivalent. The example then uses the client to fetch an entity with GetEntity:

package main
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
Lattice "github.com/anduril/lattice-sdk-go/v5"
"github.com/anduril/lattice-sdk-go/v5/client"
"github.com/anduril/lattice-sdk-go/v5/option"
"my-lattice-app/common"
)
func main() {
// Load the SKIP_TLS_VERIFY variable
skipTLSVerify := os.Getenv("SKIP_TLS_VERIFY") == "true"
LatticeClient := createLatticeClient(skipTLSVerify)
// Use the client
ctx := context.Background()
entity, err := LatticeClient.Entities.GetEntity(
ctx,
&Lattice.GetEntityRequest{
EntityID: "Demo-Sim-Asset1",
},
)
if err != nil {
fmt.Printf("Error fetching entity: %v\n", err)
} else {
fmt.Printf("Asset name | %s\n", *entity.GetAliases().GetName())
fmt.Printf("Asset location | %f, %f\n", *entity.GetLocation().GetPosition().GetLatitudeDegrees(),
*entity.GetLocation().GetPosition().GetLongitudeDegrees())
}
}
func createLatticeClient(skipTLSVerify bool) *client.Client {
// Configure the InsecureSkipVerify option. Skipping verification is unsafe: it accepts any
// certificate, so use it only against a server you trust, such as a local development server.
httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: skipTLSVerify,
},
},
}
// Take the client from my-lattice-app/common and apply the HTTP client.
return common.Connect(option.WithHTTPClient(httpClient))
}

What’s next