Skip to content

Use JDK cryptography for HTTP TLS identities - #91

Merged
BenCodez merged 2 commits into
mainfrom
codex/jdk-tls-identity
Sep 24, 2026
Merged

BenCodez merged 2 commits into
mainfrom
codex/jdk-tls-identity

Conversation

@BenCodez

@BenCodez BenCodez commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • replace Bouncy Castle certificate construction with a small JDK JCA/DER implementation
  • preserve the private CA, server/client certificate roles, SANs, key usage, PKCS#12 storage, renewal, and mutual TLS behavior
  • remove the Bouncy Castle runtime dependencies from SimpleAPI
  • keep packaged TLS verification isolated from Maven dependencies

Motivation

VotingPlugin embeds SimpleAPI. Bouncy Castle contributes roughly 7.7 MB compressed to the downstream plugin even though the HTTP transport needs only EC certificate issuance. JDK 21 already supplies EC key generation, ECDSA signing, certificate parsing, PKCS#12, and TLS.

Compatibility

  • existing PKCS#12 identity and credential stores continue to load through the JDK KeyStore and CertificateFactory
  • new certificates retain SHA256withECDSA, P-256 keys, CA constraints, digital-signature/key-signing usages, server/client EKUs, and DNS/IP/URI SANs
  • invalid IP-shaped and non-ASCII alternative names remain rejected
  • no internal sun.* APIs or module export flags are used

Validation

  • focused TLS tests: 56 passed, 0 failed/errors/skipped
  • mvn -B -f SimpleAPI/pom.xml clean package: passed
  • default tests: 404 passed, 0 failed/errors/skipped
  • packaged artifact tests: 2 passed
  • shared artifact test: 1 passed
  • packaged TLS smoke covered issuance, PKCS#12, mutual TLS, rejection, reload, server renewal, and CA renewal
  • fresh shaded JAR: 3,658,089 bytes
  • git diff --check: passed
  • final source read-only review: no findings; an isolated local reviewer was unavailable in this runtime

Downstream

VotingPlugin PR #1620 uses this change to remove the external crypto provider from its downloadable JAR.

Summary by CodeRabbit

  • TLS
    • TLS certificates continue to support client and server identities, with optional IP, DNS, or URI names.
    • Invalid IPv4 addresses and non-ASCII alternative names are rejected; IPv4-mapped IPv6 addresses are recognized.
  • Packaging
    • The packaged artifact no longer includes Bouncy Castle libraries or an external manifest classpath.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 017bc754-7559-40a5-af05-ebf9a081ebc8

📥 Commits

Reviewing files that changed from the base of the PR and between 25f5f30 and d1ee85a.

📒 Files selected for processing (7)
  • SimpleAPI/pom.xml
  • SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpClientCredentialStore.java
  • SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpTlsIdentity.java
  • SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/JdkX509CertificateGenerator.java
  • SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/HttpTransportSecurityTest.java
  • SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/PackagedTlsSmoke.java
  • SimpleAPI/src/test/java/com/bencodez/simpleapi/tests/packaging/FullArtifactTest.java
💤 Files with no reviewable changes (2)
  • SimpleAPI/pom.xml
  • SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/PackagedTlsSmoke.java

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: build
  • GitHub Check: Analyze (java-kotlin)
🔇 Additional comments (5)
SimpleAPI/src/test/java/com/bencodez/simpleapi/tests/packaging/FullArtifactTest.java (1)

22-22: LGTM!

Also applies to: 28-29, 31-31

SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/JdkX509CertificateGenerator.java (1)

1-160: LGTM!

SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpTlsIdentity.java (1)

313-313: LGTM!

Also applies to: 318-318, 342-343, 365-366, 380-380

SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpClientCredentialStore.java (1)

454-454: LGTM!

SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/HttpTransportSecurityTest.java (1)

61-81: LGTM!


📝 Walkthrough

Walkthrough

The change removes Bouncy Castle dependencies and replaces certificate creation with a JDK-based generator. TLS identity checks now use numeric X.509 identifiers and the generator’s IP-literal detection. Tests cover certificate-name validation and confirm that packaged artifacts omit Bouncy Castle.

Changes

JDK TLS certificate generation

Layer / File(s) Summary
JDK certificate generation and dependency removal
SimpleAPI/pom.xml, SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/JdkX509CertificateGenerator.java
The Maven file no longer declares Bouncy Castle dependencies. The new generator creates, signs, and parses X.509 certificates using JCA and DER-encoding helpers.
TLS identity integration and certificate checks
SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpTlsIdentity.java, SimpleAPI/src/main/java/com/bencodez/simpleapi/servercomm/http/HttpClientCredentialStore.java, SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/HttpTransportSecurityTest.java
HttpTlsIdentity delegates certificate creation and IP-literal detection to the JDK generator. TLS checks use numeric OID and SAN type values. Tests cover invalid names and IPv4-mapped IPv6 forms.
Packaged artifact checks
SimpleAPI/src/test/java/com/bencodez/simpleapi/servercomm/http/PackagedTlsSmoke.java, SimpleAPI/src/test/java/com/bencodez/simpleapi/tests/packaging/FullArtifactTest.java
The smoke test no longer requires Bouncy Castle provider registration. The artifact test checks that the manifest has no external class path and that the artifact contains no org/bouncycastle/ entries.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HttpTlsIdentity
  participant JdkX509CertificateGenerator
  participant JCA_Signature
  participant X509_CertificateFactory
  HttpTlsIdentity->>JdkX509CertificateGenerator: Pass certificate role, SAN, and issuance time
  JdkX509CertificateGenerator->>JCA_Signature: Sign encoded certificate data
  JCA_Signature-->>JdkX509CertificateGenerator: Return signature
  JdkX509CertificateGenerator->>X509_CertificateFactory: Parse encoded certificate
  X509_CertificateFactory-->>JdkX509CertificateGenerator: Return X.509 certificate
  JdkX509CertificateGenerator-->>HttpTlsIdentity: Return certificate
Loading

Merge Risk: ⚪ Minimal · up to d1ee8

No actionable merge-blocking issue is established; the change is ready for normal merge checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 34 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing Bouncy Castle with JDK cryptography for HTTP TLS identities.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T16:36:47.043521Z d1ee85a New commits
🔒 Security Review ✅ Completed 2026-09-24T16:33:46.674778Z b1fcd0e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1fcd0e8cd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (value == null || value.isEmpty()) return false;
if (value.indexOf(':') >= 0) {
if (!value.matches("[0-9A-Fa-f:.]+")) return false;
try { return InetAddress.getByName(value).getAddress().length == 16; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept IPv4-mapped IPv6 literals

When advertisedHost is a valid IPv4-mapped IPv6 literal such as ::ffff:192.0.2.1 or ::ffff:c000:201, InetAddress.getByName returns a four-byte Inet4Address, so this check returns false and create subsequently throws because the value contains a colon. The previous Bouncy Castle predicate accepted and encoded these literals, so existing deployments using them can no longer load or create their TLS identity; parse these valid mapped forms as IPv6 rather than relying on the returned address length.

AGENTS.md reference: AGENTS.md:L27-L30

Useful? React with 👍 / 👎.

@BenCodez
BenCodez merged commit e77de33 into main Sep 24, 2026
5 checks passed
@BenCodez
BenCodez deleted the codex/jdk-tls-identity branch September 24, 2026 22:11
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