klsheng / myinvois-php-sdk

MyInvois SDK for PHP
MIT License
43 stars 18 forks source link

Missing methods in KeyInfo -> X509Data #2

Closed vanjoechua closed 3 months ago

vanjoechua commented 4 months ago

Hi,

Methods to set the following seem to be missing:

X509SubjectName X509IssuerSerial -> X509IssuerName -> X509SerialNumber

Thanks!

klsheng commented 4 months ago

Currently I don't have idea how to implement this yet, the POC code still in "signature" branch. I will be very happy if you able to provide me some guide.

vanjoechua commented 4 months ago

I was able to submit the signed document to the sandbox API but needed to add this snippet to the Ubl\Builder\AbstractDocumentBuilder createSignature method

//fix 'http://www.w3.org/2000/09/xmldsig#:X509SerialNumber' element is invalid - The value  is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:integer' - The string is not a valid Integer value
$serialNumber = strval($serialNumber);
$serialNumber = substr($serialNumber,0,24);
klsheng commented 4 months ago

You need to use self-signed certification with private key and cert file in order to run the code. Cert file contains serial number and must be integer.

image

MyInvois API doesn't allow non-integer in this field.

I checked one of my paid SSL, and it contains only integer, while in my self-signed cert, it contains hex number.

vanjoechua commented 4 months ago

I was able to get a testing certificate from POS

On Fri, Jun 21, 2024 at 6:02 PM klsheng @.***> wrote:

You need to use self-signed certification with private key and cert file in order to run the code.

— Reply to this email directly, view it on GitHub https://github.com/klsheng/myinvois-php-sdk/issues/2#issuecomment-2182432763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM2ZLXAYUS5NBFBTKYWUX63ZIP23XAVCNFSM6AAAAABJVDVRKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBSGQZTENZWGM . You are receiving this because you authored the thread.Message ID: @.***>

-- Van Joe Chua

vanjoechua commented 4 months ago

You need to use self-signed certification with private key and cert file in order to run the code. Cert file contains serial number and must be integer.

image

MyInvois API doesn't allow non-integer in this field.

I checked one of my paid SSL, and it contains only integer, while in my self-signed cert, it contains hex number.

I found that if I truncate the serial number to first 24 digits the API will accept the document.

klsheng commented 3 months ago

I am waiting for test CA before can proceed further on signature branch development. You may get latest code from signature branch try at your side.

Basically

X509SubjectName X509IssuerSerial -> X509IssuerName -> X509SerialNumber

Is already in code. You may generate XML / JSON string from signature branch and cross check yourself.