Re-decode the ASN.1 TBSCertificate to accept a negative/mis-encoded serial number - #2341
Conversation
…rial number Signed-off-by: anushasunkada <anushasunkada@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
WalkthroughThe change adds tolerant DER certificate parsing for negative-encoded serial numbers. It rebuilds and reparses affected certificates, preserves original DER and TBS bytes, validates the behavior with a regression test, and wires the parser into key manager certificate handling. ChangesCertificate parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant KeyManager
participant parseCertificateTolerant
participant DERReconstruction
participant x509ParseCertificate
KeyManager->>parseCertificateTolerant: parse DER or PEM-decoded bytes
parseCertificateTolerant->>x509ParseCertificate: parse original certificate
x509ParseCertificate-->>parseCertificateTolerant: negative serial error
parseCertificateTolerant->>DERReconstruction: rebuild certificate DER
DERReconstruction-->>parseCertificateTolerant: corrected DER
parseCertificateTolerant->>x509ParseCertificate: reparse corrected certificate
x509ParseCertificate-->>parseCertificateTolerant: parsed certificate
parseCertificateTolerant-->>KeyManager: certificate with original bytes
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-go #2341 +/- ##
=============================================
Coverage ? 66.38%
=============================================
Files ? 124
Lines ? 8041
Branches ? 110
=============================================
Hits ? 5338
Misses ? 2279
Partials ? 424
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@esignet-service/internal/keymanager/certparse.go`:
- Around line 32-36: Update certparse.go around reencodeNonNegativeSerial to
extract the exact original DER encoding of the TBSCertificate sequence and
assign it to cert.RawTBSCertificate after parsing, rather than replacing only
cert.Raw with the original certificate bytes. In certparse_test.go, add coverage
using the fixture that asserts cert.RawTBSCertificate equals the original
TBSCertificate DER.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9e94943e-ca67-4319-9a05-c24492c4629a
📒 Files selected for processing (3)
esignet-service/internal/keymanager/certparse.goesignet-service/internal/keymanager/certparse_test.goesignet-service/internal/keymanager/service.go
Signed-off-by: anushasunkada <anushasunkada@gmail.com>
Summary by CodeRabbit
Bug Fixes
Tests