--- url: "https://grpc.io/docs/languages/java/alts/" titulek: "ALTS authentication | Java | gRPC" h1: "ALTS authentication" popis: "An overview of gRPC authentication in Java using Application Layer Transport Security (ALTS)." jazyk: "en" kanonicka: "https://grpc.io/docs/languages/java/alts/" drobecky: ["Docs", "Languages", "Java", "ALTS"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-13 21:00:13" znaku: 4863 slov: 434 kodovani: "utf-8" sha256: "3fd2a293fee1f510a4f4862efa8f3cd24d798a2ff987958a0a9adee94f6e2d0f" --- # ALTS authentication An overview of gRPC authentication in Java using Application Layer Transport Security (ALTS). Contents # ALTS authentication An overview of gRPC authentication in Java using Application Layer Transport Security (ALTS). ### Overview Application Layer Transport Security (ALTS) is a mutual authentication and transport encryption system developed by Google. It is used for securing RPC communications within Google’s infrastructure. ALTS is similar to mutual TLS but has been designed and optimized to meet the needs of Google’s production environments. For more information, take a look at the [ALTS whitepaper](https://cloud.google.com/security/encryption-in-transit/application-layer-transport-security). ALTS in gRPC has the following features: - Create gRPC servers & clients with ALTS as the transport security protocol. - ALTS connections are end-to-end protected with privacy and integrity. - Applications can access peer information such as the peer service account. - Client authorization and server authorization support. - Minimal code changes to enable ALTS. gRPC users can configure their applications to use ALTS as a transport security protocol with few lines of code. Note that ALTS is fully supported for connections between GCP and Google if the application runs on [Compute Engine](https://cloud.google.com/compute) or [Google Kubernetes Engine (GKE)](https://cloud.google.com/kubernetes-engine). ALTS does not support workload-to-workload authentication between GCP workloads. ### gRPC Client with ALTS Transport Security Protocol gRPC clients can use ALTS credentials to connect to servers, as illustrated in the following code excerpt: ``` import io.grpc.alts.AltsChannelBuilder; import io.grpc.ManagedChannel; ManagedChannel managedChannel = AltsChannelBuilder.forTarget(serverAddress).build(); ``` ### gRPC Server with ALTS Transport Security Protocol gRPC servers can use ALTS credentials to allow clients to connect to them, as illustrated next: ``` import io.grpc.alts.AltsServerBuilder; import io.grpc.Server; Server server = AltsServerBuilder.forPort() .addService(new MyServiceImpl()).build().start(); ``` ### Server Authorization gRPC has built-in server authorization support using ALTS. A gRPC client using ALTS can set the expected server service accounts prior to establishing a connection. Then, at the end of the handshake, server authorization guarantees that the server identity matches one of the service accounts specified by the client. Otherwise, the connection fails. ``` import io.grpc.alts.AltsChannelBuilder; import io.grpc.ManagedChannel; ManagedChannel channel = AltsChannelBuilder.forTarget(serverAddress) .addTargetServiceAccount("expected_server_service_account1") .addTargetServiceAccount("expected_server_service_account2") .build(); ``` ### Client Authorization On a successful connection, the peer information (e.g., client’s service account) is stored in the [AltsContext](https://github.com/grpc/grpc/blob/master/src/proto/grpc/gcp/altscontext.proto). gRPC provides a utility library for client authorization check. Assuming that the server knows the expected client identity (e.g., `foo@iam.gserviceaccount.com`), it can run the following example codes to authorize the incoming RPC. ``` import io.grpc.alts.AuthorizationUtil; import io.grpc.ServerCall; import io.grpc.Status; ServerCall call; Status status = AuthorizationUtil.clientAuthorizationCheck( call, Lists.newArrayList("foo@iam.gserviceaccount.com")); ``` Last modified August 11, 2021: [Trim trailing whitespace from descriptions (#822) (88d84d6)](https://github.com/grpc/grpc.io/commit/88d84d6536f7dfcc7930050e2734a8fc59e53134) [View page source](https://github.com/grpc/grpc.io/tree/main/content/en/docs/languages/java/alts.md) [Edit this page](https://github.com/grpc/grpc.io/edit/main/content/en/docs/languages/java/alts.md) [Create child page](https://github.com/grpc/grpc.io/new/main/content/en/docs/languages/java/alts.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A) [Create documentation issue](https://github.com/grpc/grpc.io/issues/new?title=ALTS%20authentication) [Create project issue](https://github.com/grpc/grpc.io/issues/new)