Fix client certificate corruption by escaping plus signs before URL decoding#13871
Fix client certificate corruption by escaping plus signs before URL decoding#13871UmairStn wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
| Comment | Accepted (Y/N) | Reason |
|---|---|---|
| #### Log Improvement Suggestion No: 1 | ||
| #### Log Improvement Suggestion No: 2 |
|
Warning Review limit reached
More reviews will be available in 4 minutes and 13 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdates Utils.getClientCertificateFromHeader to replace literal '+' with '%2B' and perform UTF-8 URL-decoding only when the certificate string is non-null; decoding exceptions are wrapped in APIManagementException. ChangesClient certificate handling
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
…/org/wso2/carbon/apimgt/gateway/handlers/Utils.java Co-authored-by: wso2-engineering[bot] <229087779+wso2-engineering[bot]@users.noreply.github.com>
…/org/wso2/carbon/apimgt/gateway/handlers/Utils.java Co-authored-by: wso2-engineering[bot] <229087779+wso2-engineering[bot]@users.noreply.github.com>
|
Problem
When
client_certificate_encode = true, the gateway decodes the client certificate header viajava.net.URLDecoder.decode(), which converts literal+characters into spaces.AWS ALB forwards certificates using RFC 3986 rules, leaving
+as a literal character. This causesURLDecoderto turn base64 + signs into spaces, corrupting the DER data and throwingjava.io.IOException: Incomplete BER/DER data.Solution
Replaced literal
+characters with%2Bright before theURLDecoder.decode()call. This ensures the decoder safely resolves them back to + instead of spaces, preserving the base64 structure.