Skip to content

[fix] match BCJSSE credential key in TLS handshakes (#383) - #394

Merged
kares merged 1 commit into
masterfrom
minimal-383-patch_squashed
Oct 27, 2026
Merged

kares merged 1 commit into
masterfrom
minimal-383-patch_squashed

Conversation

@kares

@kares kares commented Oct 27, 2026

Copy link
Copy Markdown
Member

Since 0.19, an explicit TLS version (SSLContext.new(:TLSv1_2), ssl_version= uses BCJSSE.
Our key manager picked a credential by comparing the requested key type to the credential's plain type (RSA, EC, EdDSA).

However, BCJSSE is using with different names: ECDHE_ECDSA / ECDHE_RSA / DHE_RSA / DHE_DSS in TLS 1.2, and EC/<named group>, Ed25519, Ed448 in TLS 1.3. EC client certificates were also never sent over TLS 1.3.

Related gap found along the way: Ed25519 never worked with SunJSSE provider, which is what a plain SSLContext.new (no version) uses. SunJSSE only offers an EdDSA credential when both the private key and the certificate's public key report "EdDSA". JOSSL's BC based keys report "Ed25519" - SunJSSE silently skipped the credential ("No available authentication scheme").

Resolution

  • BCJSSE: map the requested names onto the credential's key type.
    For EC/<group>, also check the certificate's curve, so a P-384 cert isn't offered for a P-256 request.
  • SunJSSE: translate EdDSA keys to SunEC keys, only when the context uses.
    The certificate bytes stay the same; only the key objects change.
    Below Java 16 SunJSSE can't do EdDSA in TLS: the credential is left as is, and a warning is logged.
  • PKeyEdDSA accepts JDK's EdDSA keys and re-reads them as BC keys.
    Previously peer_cert.public_key raised NotImplementedError for an Ed25519 cert parsed by SunJSSE.

fixes #383 (supersedes #384)

BCJSSE requests cipher authentication names in TLS 1.2 and named EC
groups or concrete EdDSA algorithms in TLS 1.3

exact matching against stored key types drops valid EC and EdDSA
credentials during the handshake - match those requests against the
certificate key and full EC group

+ translate EdDSA credential keys for SunJSSE

SunJSSE only offers an EdDSA credential when both the private key and
the certificate's public key report "EdDSA", BC keys report
Ed25519/Ed448 so the credential got silently skipped ("No available
authentication scheme")

this affected Ed25519 certs with a plain SSLContext.new (SunJSSE is used
without an explicit TLS version) on both server and client side

translate keys to SunEC at setup only when needed (SunJSSE + EdDSA keys
not already reporting "EdDSA"), keeping the certificate bytes as is
@kares
kares force-pushed the minimal-383-patch_squashed branch from d45c9c1 to a361e0a Compare October 27, 2026 13:02
@kares kares added this to the 0.19.4 milestone Oct 27, 2026
@kares
kares merged commit 9ce80aa into master Oct 27, 2026
160 checks passed
@kares
kares deleted the minimal-383-patch_squashed branch October 27, 2026 13:20
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.

TLS server with an EC key fails on 0.19.x (chooseAlias doesn't match BCJSSE key types)

1 participant