Update InvoiceExtension.php | Fix: Sanitize Certificate Public Key Base64 Data for ZATCA QR Generation#27
Closed
khaledhajsalem wants to merge 1 commit intoSaleh7:mainfrom
Closed
Update InvoiceExtension.php | Fix: Sanitize Certificate Public Key Base64 Data for ZATCA QR Generation#27khaledhajsalem wants to merge 1 commit intoSaleh7:mainfrom
khaledhajsalem wants to merge 1 commit intoSaleh7:mainfrom
Conversation
fix(qr): sanitize certificate base64 data to prevent ZATCA validation errors - Remove whitespace characters from getRawPublicKey() output - Add cleanCertificateBase64() method for robust data handling - Fixes QR Tag 8 corruption causing compliance failures
Owner
|
Thank you |
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.
🐛 Fix: Sanitize Certificate Public Key Base64 Data for ZATCA QR Generation
Problem
When generating ZATCA-compliant QR codes, the
getRawPublicKey()method sometimes returns base64 data containing whitespace characters (spaces, newlines, tabs), which corrupts the binary certificate data in Tag 8 of the TLV structure. This causes QR validation to fail with ZATCA's validation system.Root Cause
The certificate extraction process can introduce formatting characters from:
Example Issue
✅ Valid base64:
77+9IANC77+9BAnSqDp+EQJMCQt+❌ Corrupted base64:
77 9IANC77 9BAnSqDp EQJMCQtThe spaces break the base64 encoding, resulting in invalid binary data for the X.509 certificate in Tag 8.
Changes Made
getCleanCertificatePublicKey()method to sanitize certificate datagetRawPublicKey()output processingCode Added
Impact
Before:
After:
Testing
Environment
Breaking Changes
None. This is a backward-compatible fix that only cleans data when necessary.