Nodejs ssl3_get_record wrong version number

Viewed 3421

For the past few months I've been working on a project involving Nodejs (12.16.1). I've created a backend API (database and other resources) and an authentication service. Im currently updating a Discord bot that uses nodejs (all using the same node version and same node-fetch). The bot is having issues connecting to the Backend API. Using node-fetch with the following error

request to https://<host:port>/api/bot/<resource> failed, reason: write EPROTO 1988:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\\ws\\deps\\openssl\\openssl\\ssl\\record\\ssl3_record.c:332:\n

Im not using a Proxy, infact its a dev environment all running under localhost. Which has been running without an issue for months. Now for the interesting part. The bot will POST fine to the authentication service but will fail when using POST or GET to the Backend. Postman will have no issue accessing the APIs. Thinking it was the certificate I made a new one (self-signed) but i still get the same error message.

So I used Wireshark and captured the traffic between the Bot the Authentication service and the Backend. When the bot talks to the Authentication services it does the Hello client / server messages in TLS 1.3. However when it talks to the backend it tries to use TLS 1.0.

Thinking any new current code was causing issues i pulled a fresh copy of the Backend and the Bot from my repo and tried again. Even the current Live builds will fail with the same error message. I have no clue what is going, I've only been coding for a few months and this is the first wall I've hit that i can't seem to figure out. Goolge and even stack hasn't been much help as an ssl3 wrong version errors have been left unanswered or don't line up with my issue (most people seem to have this issue when using Proxies).

The only thing that has updated software wise was the latest Windows 10 updates. KB4598242, KB4023057

Thanks.

Edit. server.js

const port = process.env.PORT;

const key = fs.readFileSync('./server.key');
const cert = fs.readFileSync('./server.cert');
app.use(jwt());
app.use(express.json());
app.use(cors());
app.use('/api/bot', require('routes/botapi'));
const server = https.createServer({'key': key, 'cert': cert}, app);
server.listen(port, () => { console.log(chalk.green(`[SERVER]`) + `: listening on ${port}`) });

botapi.js

...requires
const botRouter = express.Router();

botRouter.post('/updatemembers', discordUpdateMembers);

async function discordUpdateMembers(req, res, next) {
    let validRole = await hasBotRole(req);
    if (!validRole) return res.status(400).send({err: 'Access_Denied!!'});
    discord.updateMembers(req.body)
    .then(members => members ? res.json(members) : res.status(400))
    .catch(err => next(err));
}
0 Answers
Related