Cannot read property 'trim' of undefined

Hello,

I am trying to connect my Netsuite sandbox account with the Fatoora simulation portal.

I have generated a private key and a CSR and I have the OTP from the simulation portal.

However, when I attempt to connect Netsuite to the portal I get this error: Cannot read property ‘trim’ of undefined.

Looking deeper into the execution logs I can see this error: app_ksa_error_manager:code body: 400-{“errorCode”:“400”,“errorCategory”:“Invalid-CSR”,“errorMessage”:“The provided Certificate Signing Request (CSR) is invalid.”}

I also see
su_ksa_getccsid: e: TypeError: Cannot read property ‘trim’ of undefined
and
errors Arrays : "undefined"undefined

So I can see that my CSR is invalid, and it looks like it is because there is an undefined value somewhere, but I can’t understand what or where or why.

I am not a coder so I am really flying blind here and just have the Netsuite documentation to go by, which doesn’t have any kind of trouble shooting like this.

Any advice on what my issues might be and where I can start looking would be really helpful.

Thanks,

Luke

Dear @Luke

Thanks for reaching out.

Can you please elaborate more on the steps you have taken to generate the CSR? Also, please refer to the SDK by following this path:
(zatca-einvoicing-sdk-238-R3.3.3\Data\Input), which contains samples of the config file data that you will generate your CSR from,

Additionally, please see E-invoicing-Detailed-Technical-Guideline.pdf (zatca.gov.sa) slide 26, which explains all the fields in the config file you must provide.

For any further support, please don’t hesitate to reach out.

Thanks.
Ibrahem Daoud.

Hi,

Thanks for coming back to me.

Below are the steps I took to generate the CSR:

I saved a txt file called csr_config.txt. The contents of the file are below (I have added XXXX to replace sensitive information I don’t want to post publically). I created the file following the instructions here: NetSuite Applications Suite - Obtaining a Certificate Signing Request, Private Key, and Compliance Binary Security Token

oid_section = OIDs
[OIDs]
certificateTemplateName = 1.3.6.1.4.1.311.20.2
[req]
default_bits = 2048
emailAddress = XXXX.XXXX@mcsaatchi.com
req_extensions = v3_req
x509_extensions = v3_ca
prompt = no
default_md = sha 256
req_extensions = req_ext
distinguished_name = dn
[dn]
C=SA
OU=M and C Saatchi Arabia Limited Liability Company
O=M and C Saatchi Arabia Limited Liability Company
CN=Oracle NetSuite MCSaatchi EGS Unit
[v3_req]
basicConstraints = CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment
[req_ext]
certificateTemplateName = ASN1:PRINTABLESTRING:ZATCA-Code-Signing
subjectAltName = dirName:alt_names
[alt_names]
SN=1-MCSaatchi|2-oracleNetsuite|3-XXXX
UID=3XXXXXXXXXXXXX3
title=1100
registeredAddress=Al Riyad, Al Zahraa, Al Ihsa, 12815
businessCategory=Media

I am using a Mac. So in the Terminal App I run the following instruction: openssl ecparam -name prime256v1 -genkey -noout -out privateKey.pem

This generates a private key file.

Then I run this instruction: openssl req -new -sha256 -key privateKey.pem -extensions v3_req -config csr_config.txt -out taxpayer.csr

This generated a CSR file.

In Terminal I run an instruction to show me the two keys, which I am then putting into the Saudi Arabia Einvoicing Configuration Page within Netsuite.

You mentioned about ‘following the path’ (zatca-einvoicing-sdk-238-R3.3.3\Data\Input). I’m not a coder so I don’t really know what these means. How can I see the examples of the config file data?

Any help would be greatly appreciated. Thanks!

Dear @Luke

What API are you using core or simulation ?

Hi,

I’m using Simulation. I’m trying to connect our Netsuite sandbox account to the Fatoora simulation portal.

Dear @Luke

Please send the details on sp_support@zatca.gov.sa and E-invoicing@zatca.gov.sa

Thanks,

OK thank you I will email them

How long should I have to expect to wait for a reply?
Thanks,

Dear @Luke

You can send a reminder.

Thanks,
Ibrahem Daoud.

Hi,

OK thanks I have, but I also didn’t receive any kind of acknowledgement of my email. Should I have? Do they have a response time?

Thanks

They still haven’t replied, what can I do from here?

I was finally able to speak with the Netsuite product team. In case anyone else reads this in the future with the same issue, I am posting the solultion here. The issue was that I wasn’t including the:

-----BEGIN CERTIFICATE REQUEST-----
-----END CERTIFICATE REQUEST-----

lines that are at the start and the end of the private key or CSR, I was just putting in the actual encrypted code. So that is the answer! I don’t know whether to face palm or to be justified in that it wasn’t obvious at all they needed to be included. Anyway, now it is connecting. Thanks.