Dockerfile from "adk deploy agent_engine" ignores "AGENT_GATEWAY_ROOT_CERTIFICATES" build arg, causing runtime SSL handshake failures
🔴 Required Information
Describe the Bug:
When deploying an agent to Gemini Enterprise Agent Runtime (fka. Vertex AI Agent Engine) with Agent Gateway enabled (agent_gateway_config.agent_to_anywhere_config and identity_type="AGENT_IDENTITY"), adk deploy agent_engine generates a Dockerfile that does not declare or consume the AGENT_GATEWAY_ROOT_CERTIFICATES build argument passed by Cloud Build.
Consequently, the custom TLS inspection root CA certificate for the Agent Gateway is not installed into the container trust store (/etc/ssl/certs/ca-certificates.crt), causing all outbound HTTPS and gRPC calls (Gemini API, BigQuery, MCP Toolbox, etc.) routed through the Gateway to fail at runtime with SSL certificate verification errors.
Steps to Reproduce:
- Configure an agent with
.agent_engine_config.jsonspecifying an Agent Gateway:{ "agent_gateway_config": { "agent_to_anywhere_config": { "agent_gateway": "projects/PROJECT_ID/locations/LOCATION/agentGateways/GATEWAY_NAME" } }, "identity_type": "AGENT_IDENTITY" } - Deploy the agent using the ADK CLI:
adk deploy agent_engine --project=PROJECT_ID --region=LOCATION agent_dir - Check Cloud Build logs and observe the unused build-arg warning.
- Send a query to the deployed Reasoning Engine that invokes any outbound tool, database query, or model API call.
Expected Behavior:
The Dockerfile generated by adk deploy agent_engine should accept ARG AGENT_GATEWAY_ROOT_CERTIFICATES, write the certificate to /usr/local/share/ca-certificates/, and run update-ca-certificates. Outbound TLS traffic through the Agent Gateway should complete successfully without SSL verification errors.
Observed Behavior:
- Cloud Build Warning:
[Warning] One or more build-args [AGENT_GATEWAY_ROOT_CERTIFICATES] were not consumed - Runtime Error:
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)
Environment Details:
- ADK Library Version:
2.5.0 - Desktop OS: macOS / Linux
- Python Version:
3.11+
Model Information:
- Are you using LiteLLM: No
- Which model is being used:
gemini-3.5-flash
🟡 Optional Information
Regression: N/A
Logs:
Step 13/13 : CMD adk api_server --port=8080 --host=0.0.0.0 --session_service_uri=...
[Warning] One or more build-args [AGENT_GATEWAY_ROOT_CERTIFICATES] were not consumed
Successfully built container
... at runtime ...
google.api_core.exceptions.RetryError: Timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses; last error: FAILED_PRECONDITION: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)
Additional Context:
Deploying via the native Vertex AI Python SDK (vertexai.agent_engines.AdkApp via client.agent_engines.create(agent=..., config=...)) works as expected because Vertex AI's managed source package template natively consumes ARG AGENT_GATEWAY_ROOT_CERTIFICATES and executes update-ca-certificates. The issue is strictly isolated to the Dockerfile generated in google/adk/cli/cli_deploy.py (_DOCKERFILE_TEMPLATE).
Possible Fix in google/adk/cli/cli_deploy.py:
Add the build argument and CA update step to _DOCKERFILE_TEMPLATE:
ARG AGENT_GATEWAY_ROOT_CERTIFICATES
RUN if [ -n "$AGENT_GATEWAY_ROOT_CERTIFICATES" ]; then \
mkdir -p /usr/local/share/ca-certificates && \
echo "$AGENT_GATEWAY_ROOT_CERTIFICATES" > /usr/local/share/ca-certificates/agw-ca.crt && \
update-ca-certificates; \
fi
How often has this issue occurred?:
- Always (100%)
Working on a fix: consume AGENT_GATEWAY_ROOT_CERTIFICATES in _DOCKERFILE_TEMPLATE (install into system CA trust before switching to non-root user). Opening a PR shortly.
Hello @KenTandrian ,
Thank you for reporting this issue. We have reviewed it and checked linked PR #6428 , which should address the problem. Could you please take a look at it and let us know if this resolves the issue for you?
Additionally, this PR will be merged as soon as the changes are reviewed and approved by assigned reviewers.
Hi @llalitkumarrr,
I tested PR #6428, and I can confirm that the original build-arg warning ([Warning] build-args [AGENT_GATEWAY_ROOT_CERTIFICATES] were not consumed) and the basic [SSL: CERTIFICATE_VERIFY_FAILED] error are now resolved.
However, the deployed agent is still unable to answer queries due to runtime mTLS timeouts on .mtls. endpoints, e.g. asia-southeast1-aiplatform.mtls.googleapis.com and telemetry.mtls.googleapis.com (when enabling telemetry):
Retrying due to aiohttp error: Failed to send request to https://asia-southeast1-aiplatform.mtls.googleapis.com/v1beta1/...
ConnectionAbortedError: SSL handshake is taking longer than 60.0 seconds: aborting the connection
I can confirm that I have added the endpoints to Agent Registry and given IAP-secured Egressor role to the agent identity.
Also, during the Cloud Build step in PR #6428, I noticed this warning in the logs:
Updating certificates in /etc/ssl/certs...
rehash: warning: skipping ca-certificates.crt, it does not contain exactly one certificate or CRL
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
I am not sure if it is something we should look into.
Let me know if there are additional configurations or logs I can provide to help troubleshoot this further.
Hello @wuliang229 ,
Could you please take a look at this?
rg AGENT_GATEWAY_ROOT_CERTIFICATES src/google/adk/cli/cli_deploy.py prints nothing on main, so _DOCKERFILE_TEMPLATE has no ARG for it. #6428 shows closed on 2026-08-12 with no GitHub merge. I will add the ARG and a root-only update-ca-certificates RUN before USER myuser.
Resolved by #7048 (imported and merged in commit 2ba3e2d). Closing issue.