The error message you’re encountering, An untrusted, unsupported, or invalid certificate was found for this host, indicates that the HTTPS request to the specified endpoint (https://rspportal.net/api/tasks) is being blocked due to certificate issues. Here are some steps to troubleshoot and resolve this problem:
1. Check SSL Certificate Validity
- Ensure that the SSL certificate for
rspportal.netis valid, not expired, and correctly installed. - You can check the certificate details by accessing the URL in a web browser and inspecting the security information.
2. Update HTTPS Configuration
- If the certificate is self-signed or issued by an untrusted certificate authority (CA), consider obtaining a certificate from a trusted CA.
- If it’s necessary to use a self-signed certificate, you might need to configure your script or NetSuite settings to trust it.
3. NetSuite Configuration
- Check if your NetSuite account has any specific settings or configurations that restrict outgoing requests to untrusted hosts. Ensure that any required permissions or settings are properly configured.
4. Debugging Logs
- Utilize the
log.debugstatements in yourpostRequest,putRequest, anddeleteRequestmethods to gather more information about the requests and responses. - Look at the specific line causing the error (
rspdc_project_api_cm_library.js:63:38) and add more logging if necessary to identify the payload and endpoint being used.
5. Try a Different Endpoint
- As a temporary measure, if possible, test with a different API endpoint that you know is trusted and has a valid certificate to verify if the issue is indeed with the SSL certificate of the current endpoint.
6. Using a Proxy or Alternative Network
- If you’re testing in an environment with strict network policies, try using a different network or setting up a proxy that might have different certificate handling policies.
Example Debugging Code Snippet
You can add additional logging to see the request details before making the call:
javascript
postRequest: (payLoadJSON, endPoint) => {
try {
log.debug('Endpoint URL', endPoint);
log.debug('Payload JSON', JSON.stringify(payLoadJSON)); // Log the payload
let returnVal = {};
let headerObj = {
"Content-Type": "application/json",
"Accept-Language": "en-us",
};
let response = https.post({
url: `${endPoint}`,
body: `${JSON.stringify(payLoadJSON)}`,
headers: headerObj
});
log.debug("Response Code", response.code); // Log the response code
log.debug("Response Body", response.body); // Log the response body
if (Object.values(SUCCESS_API_RESPONSES).some(el => el === response.code)) {
returnVal = {
"STATUS": "SUCCESS",
"DATA": response.body ? JSON.parse(response.body) : ""
};
} else {
returnVal = {
"STATUS": "FAILURE",
"DATA": [],
"MESSAGE": response.body || "Unknown error"
};
}
return returnVal;
} catch (err) {
log.error("error@postRequest", err);
return {
"STATUS": "FAILURE",
"DATA": [],
"MESSAGE": err.message
};
}
},
Conclusion
By addressing the SSL certificate issue and implementing additional logging, you should be able to identify the root cause and rectify the problem. If the issue persists after confirming the certificate’s validity, consider reaching out to your network or API provider for further assistance.