I’m experiencing an odd SSL certificate error when my Discord bot tries to connect to the API. The error message indicates “unable to get local issuer certificate” and I can’t determine what the issue is. Here is the precise error message I encounter:
HTTPError [FetchError]: request to https://discord.com/api/v9/gateway/bot failed, reason: unable to get local issuer certificate
at ResponseHandler.process (C:\MyBot\node_modules\discord.js\src\rest\ResponseHandler.js:198:12)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ResponseHandler.send (C:\MyBot\node_modules\discord.js\src\rest\ResponseHandler.js:48:11)
at async SocketManager.initialize (C:\MyBot\node_modules\discord.js\src\client\websocket\SocketManager.js:127:8)
at async Client.connect (C:\MyBot\node_modules\discord.js\src\client\Client.js:251:6) {
code: 500,
method: 'get',
path: '/gateway/bot',
requestData: { json: undefined, files: [] }
}
Here’s the section of my code responsible for handling requests:
// Execute the HTTP request
let response;
try {
response = await httpRequest.send();
} catch (err) {
// Retry logic for failed requests
if (httpRequest.attempts === this.handler.client.options.maxRetries) {
throw new HTTPError(err.message, err.constructor.name, err.status, httpRequest);
}
httpRequest.attempts++;
return this.process(httpRequest);
}
if (this.handler.client.listenerCount(API_EVENT)) {
/**
* Fired when API request completes
* @event BaseClient#apiEvent
* @param {HTTPRequest} httpRequest The original request
* @param {Response} response The API response
*/
this.handler.client.emit(
API_EVENT,
{
method: httpRequest.method,
path: httpRequest.path,
route: httpRequest.route,
options: httpRequest.options,
attempts: httpRequest.attempts,
},
response.clone(),
);
}
I’ve looked everywhere but still can’t find a solution. Any suggestions on what might be the problem?