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
Conversation
coo-mdsol
marked this pull request as ready for review
September 8, 2026 03:05
coo-mdsol
requested review from
ykitamura-mdsol
and
a balanced review from Copilot
September 8, 2026 03:14
Contributor
There was a problem hiding this comment.
🟡 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.
coo-mdsol
force-pushed
the
fix-private-key-load-error
branch
from
September 8, 2026 04:17
5f93fbf to
2ac9dd8
Compare
coo-mdsol
force-pushed
the
fix-private-key-load-error
branch
from
September 8, 2026 05:03
2ac9dd8 to
124af16
Compare
ValueError instead of a pyasn1 error when a private key cannot be loaded
ykitamura-mdsol
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
to_rsa_formatwrapping non-PEM values (such as a KMS-encrypted key) in-----BEGIN RSA PRIVATE KEY-----markers, which madelambda_helperskip KMSdecryption and pass the ciphertext to the RSA loader
\n(or\r\n) sequences,which previously corrupted the base64 body and raised a
pyasn1decoding errormauth_client.lambda_helpermangling PKCS#8 (-----BEGIN PRIVATE KEY-----) keysValueErrorinstead of apyasn1error when a private key cannot be loaded