• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

165
Views
How to know if the key and certificate are using?

I'm working on the Express API Javascript code in a way that uses the self-signed SSL certificate.

I created a self-signed SSL certificate using: https://helpcenter.gsx.com/hc/en-us/articles/115015960428-How-to-Generate-a-Self-Signed-Certificate-and-Private-Key-using-OpenSSL

Then, I put the privateKey.key, certificate.crt, and server.js in the same folder.

Server.js

const express = require("express");
const fs = require("fs");
const app = express();
const port = 443;

app.get("/", (req, res) => {
  res.send("IT'S WORKING!");
});

require("http")
  .createServer(
    {
      key: fs.readFileSync("privateKey.key"),
      cert: fs.readFileSync("certificate.crt"),
    },
    app
  )
  .listen(port, () => {
    console.log(`Listening on port ${port}!`);
  });

I ran nodemon server.js in terminal and below is the output:

[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Listening on port 443!

I tested it in the browser by localhost:443. Then the response IT'S WORKING showed up.

My question is Am I doing correctly to the Express API Javascript code with the self-signed SSL certificate? How to know exactly the self-signed SSL certificate is being used?

Thank you so much

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use Wireshark to capture the client's and server's handshake data. Your SSL certificate should be in one of the server's responses data.

almost 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error