Skip to content

An API signed by a private authority is reached by trusting that authority for its client alone - #56

Merged
johnsonr merged 2 commits into
mainfrom
feat/api-trusted-certificates
Nov 17, 2026
Merged

johnsonr merged 2 commits into
mainfrom
feat/api-trusted-certificates

Conversation

@johnsonr

Copy link
Copy Markdown
Contributor

What

OpenApiClientProperties gains trustedCertificates. The tools built with those properties trust the given certificates in place of the JVM's authorities. No other client is affected, and there is no option to stop verifying.

The text is what an operator already has:

  • one or more PEM certificates;
  • PEM with \n for its line breaks, as a single-line setting carries it;
  • Base64 of PEM or DER, which is what a kubeconfig's certificate-authority-data is.

Text that holds no certificate is refused with IllegalArgumentException, never ignored.

Why

A Kubernetes cluster's API is signed by the cluster's own authority, as most APIs inside an organisation are. Today the choices are to add that authority to the JVM's trust store, which trusts it for every call the application makes, or to stop verifying. A host that learns an API per installation (Embabel Me's realms) needs to say 'trust this authority for this API'.

How

  • TrustedCertificates parses the text and builds an SSLContext over those certificates only.
  • SharedHttpClients.redirectRefusing keys its shared client by connect timeout and the fingerprint of the trusted certificates, so the thread bound from OpenApiLearner builds an HttpClient per learned tool and never closes it #51/HttpProbeTool's HttpClient is never closed #52 holds: one client per configuration, whatever form the certificates were written in.
  • CredentialSafeRedirects.overJdkClient has an overload taking them; OpenApiLearner.buildRestClient passes them through.
  • OpenApiClientProperties keeps its existing constructors for Java callers (@JvmOverloads).

Tests

TrustedCertificatesTest (6, new) starts an HTTPS server holding a certificate made at test time by the JDK's keytool, so nothing is checked in:

  • a client given the authority reaches it;
  • a client not given it is refused with SSLHandshakeException;
  • the three written forms all work;
  • text with no certificate is refused;
  • one client is shared per authority, distinct from the default one.

SharedHttpClientsTest (6) and CredentialSafeRedirectsTest (7) still pass.

Not in this PR

  • The GraphQL client does not take trusted certificates yet.
  • Client certificates (mutual TLS).

🤖 Generated with Claude Code

johnsonr and others added 2 commits November 17, 2026 18:53
…ority for its client alone

A Kubernetes cluster's API, like most APIs inside an organisation, is signed by an authority no
public trust store carries. OpenApiClientProperties gains trustedCertificates: PEM, PEM with \n
for its line breaks, or Base64 of PEM or DER (a kubeconfig's certificate-authority-data). The
tools built with those properties trust those certificates in place of the JVM's authorities;
no other client does, and nothing stops verifying.

The JDK clients stay shared: SharedHttpClients keys a redirect-refusing client by connect timeout
and by the fingerprint of the certificates it trusts, so there is one per configuration.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6e7yb6kDzgxADRVhasCrL
LearnedApiSpec.toFactory takes the OpenApiClientProperties its tools are built with, so an API
loaded from its kept spec trusts the same authority, and has the same timeouts, as one just learned.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F6e7yb6kDzgxADRVhasCrL
@johnsonr
johnsonr merged commit 89f0f51 into main Nov 17, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant