Skip to content

fix: Fix private key normalization error and raise a clear ValueError instead of a pyasn1 error when a private key cannot be loaded - #64

Merged
ykitamura-mdsol merged 2 commits into
mainfrom
fix-private-key-load-error
Sep 8, 2026
Merged

fix: Fix private key normalization error and raise a clear ValueError instead of a pyasn1 error when a private key cannot be loaded#64
ykitamura-mdsol merged 2 commits into
mainfrom
fix-private-key-load-error

Conversation

@coo-mdsol

@coo-mdsol coo-mdsol commented Sep 8, 2026

Copy link
Copy Markdown
Contributor
  • Fix to_rsa_format wrapping non-PEM values (such as a KMS-encrypted key) in
    -----BEGIN RSA PRIVATE KEY----- markers, which made lambda_helper skip KMS
    decryption and pass the ciphertext to the RSA loader
  • Fix loading of private keys stored as one-liners with escaped \n (or \r\n) sequences,
    which previously corrupted the base64 body and raised a pyasn1 decoding error
  • Fix mauth_client.lambda_helper mangling PKCS#8 (-----BEGIN PRIVATE KEY-----) keys
  • Raise a clear ValueError instead of a pyasn1 error when a private key cannot be loaded

@coo-mdsol coo-mdsol changed the title fix decode error Fix decode error Sep 8, 2026
@coo-mdsol
coo-mdsol marked this pull request as ready for review September 8, 2026 03:05
@coo-mdsol
coo-mdsol requested review from ykitamura-mdsol and a balanced review from Copilot September 8, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Add the missing malformed-PEM error regression test and correct the changelog version heading.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes private-key normalization and loading failures in standard and AWS Lambda configurations.

Changes:

  • Preserves KMS-encrypted values and normalizes escaped newlines.
  • Supports PKCS#1 and PKCS#8 keys.
  • Converts pyasn1 failures into clear ValueErrors.
  • Adds regression coverage and bumps the patch version.
File summaries
File Description
tests/utils_test.py Tests private-key normalization scenarios.
tests/lambda_helper_test.py Tests Lambda key handling and KMS decryption.
pyproject.toml Bumps the package version to 1.10.1.
mauth_client/utils.py Improves PEM detection and escaped-newline normalization.
mauth_client/rsa_signer.py Translates pyasn1 failures to ValueError; malformed-PEM regression coverage is still needed.
mauth_client/lambda_helper.py Handles encrypted values and PKCS#8 keys correctly.
CHANGELOG.md Documents the release; the version heading should be corrected to 1.10.1.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread mauth_client/rsa_signer.py
Comment thread CHANGELOG.md Outdated
@coo-mdsol
coo-mdsol force-pushed the fix-private-key-load-error branch from 5f93fbf to 2ac9dd8 Compare September 8, 2026 04:17
@coo-mdsol
coo-mdsol force-pushed the fix-private-key-load-error branch from 2ac9dd8 to 124af16 Compare September 8, 2026 05:03
@coo-mdsol coo-mdsol changed the title Fix decode error Fix private key normalization error Sep 8, 2026
@ykitamura-mdsol ykitamura-mdsol changed the title Fix private key normalization error fix: Fix private key normalization error and raise a clear ValueError instead of a pyasn1 error when a private key cannot be loaded Sep 8, 2026
@ykitamura-mdsol
ykitamura-mdsol merged commit 1a25776 into main Sep 8, 2026
20 checks passed
@ykitamura-mdsol
ykitamura-mdsol deleted the fix-private-key-load-error branch September 8, 2026 07:23
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.

3 participants