Connect - Agent HTTP API
The /agent/connect
endpoints interact with
with agent-local service mesh operations.
These endpoints may mirror the non-agent service mesh endpoints in some cases. Almost all agent-local service mesh endpoints perform local caching to optimize performance of the mesh without having to make requests to the server.
Authorize
Note: This endpoint will always treat intentions with Permissions
defined as deny intentions during evaluation, as this endpoint is only suited
for networking layer 4 (e.g. TCP) integration.
For performance and reliability reasons it is desirable to implement intention
enforcement by listing intentions that match the
destination and representing
them in the native configuration of the proxy itself (such as RBAC for Envoy).
This endpoint tests whether a connection attempt is authorized between two services. This is the primary API that must be implemented by proxies or native integrations that wish to integrate with the service mesh. Prior to calling this API, it is expected that the client TLS certificate has been properly verified against the current CA roots.
The implementation of this API uses locally cached data and doesn't require any request forwarding to a server. Therefore, the response typically occurs in microseconds to impose minimal overhead on the connection attempt.
Method | Path | Produces |
---|---|---|
POST | /agent/connect/authorize | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
NO | none | background refresh | service:write |
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the target service. You can also specify the namespace through other methods.
JSON Request Body Schema
Target
(string: <required>)
- The name of the service that is being requested.ClientCertURI
(string: <required>)
- The unique identifier for the requesting client. This is currently the URI SAN from the TLS client certificate.ClientCertSerial
(string: <required>)
- The colon-hex-encoded serial number for the requesting client cert.Namespace
(string: "")
Enterprise - Specifies the namespace of the target service. This field takes precedence over thens
query parameter, one of several other methods to specify the namespace.
Sample Payload
Sample Request
Sample Response
Certificate Authority (CA) Roots
This endpoint returns the trusted certificate authority (CA) root certificates. This is used by proxies or native integrations to verify served client or server certificates are valid.
This is equivalent to the non-Agent service mesh endpoint, but the response of this request is cached locally at the agent. This allows for very fast response times and for fail open behavior if the server is unavailable. This endpoint should be used by proxies and native integrations.
Method | Path | Produces |
---|---|---|
GET | /agent/connect/ca/roots | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | background refresh | none |
Sample Request
Sample Response
Service Leaf Certificate
This endpoint returns the leaf certificate representing a single service. This certificate is used as a server certificate for accepting inbound connections and is also used as the client certificate for establishing outbound connections to other services.
The agent generates a CSR locally and calls the CA sign API to sign it. The resulting certificate is cached and returned by this API until it is near expiry or the root certificates change.
Non blocking queries to this endpoint will always check that the leaf certificate is not expired and that the root certificates have not changed. Otherwise, a new leaf certificate is generated.
This API supports blocking queries. The blocking query will block until a new certificate is necessary (because the existing certificate will expire, is expired, or the root certificate is being rotated), or until the query timeout is reached. The current query timeout is set to 10 minutes. This blocking behavior allows clients to wait for certificate rotations.
Method | Path | Produces |
---|---|---|
GET | /agent/connect/ca/leaf/:service | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes, agent caching, and required ACLs.
Blocking Queries | Consistency Modes | Agent Caching | ACL Required |
---|---|---|---|
YES | all | background refresh | service:write |
Path Parameters
service
(string: <required>)
- The name of the service for the leaf certificate. The service does not need to exist in the catalog, but the proper ACL permissions must be available.
Query Parameters
ns
(string: "")
Enterprise - Specifies the namespace of the leaf certificate you request. You can also specify the namespace through other methods.
Sample Request
Sample Response
SerialNumber
string
- Monotonically increasing 64-bit serial number representing all certificates issued by this Consul cluster.CertPEM
(string)
- The PEM-encoded certificate.PrivateKeyPEM
(string)
- The PEM-encoded private key for this certificate.Service
(string)
- The name of the service that this certificate identifies.ServiceURI
(string)
- The URI SAN for this service.ValidAfter
(string)
- The time after which the certificate is valid. Used withValidBefore
this can determine the validity period of the certificate.ValidBefore
(string)
- The time before which the certificate is valid. Used withValidAfter
this can determine the validity period of the certificate.
Methods to specify namespace Enterprise
Local agent service mesh endpoints support several methods for specifying the namespace of resources with the following order of precedence:
Namespace
field of the JSON request body - only applies to the register endpointns
query parameterX-Consul-Namespace
request header- Namespace is inherited from the namespace of the request's ACL token (if any)
- The
default
namespace