Skip to content

fix(client/tls): correct PEM label and add Ed25519 key support#452

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/github-ai-quality
May 14, 2026
Merged

fix(client/tls): correct PEM label and add Ed25519 key support#452
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:fix/github-ai-quality

Conversation

@fredbi
Copy link
Copy Markdown
Member

@fredbi fredbi commented May 14, 2026

TLSClientAuth marshaled RSA keys as PKCS#1 and ECDSA keys as SEC1, then labeled both PEM blocks as "PRIVATE KEY" — a label conventionally reserved for PKCS#8. The output round-tripped through tls.X509KeyPair only because Go's parser is lenient; stricter consumers would reject it.

Switch to a single x509.MarshalPKCS8PrivateKey call, which matches the "PRIVATE KEY" label naturally and transparently supports Ed25519 (previously rejected by the type switch's default branch).

Also fix gencerts_test.go: writePKCS1KeyPair wrote PKCS#1 RSA bytes under an "EC PRIVATE KEY" label — same class of latent mislabel.

Adds an Ed25519 subtest under TestRuntimeTLSOptions.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

TLSClientAuth marshaled RSA keys as PKCS#1 and ECDSA keys as SEC1,
then labeled both PEM blocks as "PRIVATE KEY" — a label conventionally
reserved for PKCS#8. The output round-tripped through tls.X509KeyPair
only because Go's parser is lenient; stricter consumers would reject it.

Switch to a single x509.MarshalPKCS8PrivateKey call, which matches the
"PRIVATE KEY" label naturally and transparently supports Ed25519
(previously rejected by the type switch's default branch).

Also fix gencerts_test.go: writePKCS1KeyPair wrote PKCS#1 RSA bytes
under an "EC PRIVATE KEY" label — same class of latent mislabel.

Adds an Ed25519 subtest under TestRuntimeTLSOptions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi merged commit eaa96ed into go-openapi:master May 14, 2026
19 checks passed
@fredbi fredbi deleted the fix/github-ai-quality branch May 14, 2026 21:26
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.06%. Comparing base (1c5e373) to head (d62bea7).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
client/tls.go 33.33% 1 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (33.33%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #452      +/-   ##
==========================================
+ Coverage   85.04%   85.06%   +0.02%     
==========================================
  Files          60       60              
  Lines        3978     3970       -8     
==========================================
- Hits         3383     3377       -6     
+ Misses        451      449       -2     
  Partials      144      144              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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