Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
What HTTP code do you get if an SSL has expired?

I have a custom monitor code setup. I need to check if the specified URL has its SSL certificate expired. Is there a specific HTTP code for this? For example:

(async() => {
    const res = await fetch('http://example.com');
    // Or `statusText`
    if (res.status == some_ssl_expiryCode) {
        console.log('SSL expired!');
    }
})();

Is there a way to do this in javascript?

Thank you.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The client application receives an HTTP 400 - Bad request response with the message "The SSL certificate error".

about 4 years ago · Juan Pablo Isaza Report

0

As @Jasen said, the connection doesn't reach the server. The fetch request returns the error CERT_HAS_EXPIRED or CERT_INVALID. It does not produce an HTTP code. See the javascript code below.

import fetch from 'node-fetch';

fetch('https://example.com/')
    .then(async(res) => await res.text())
    .then(() => { // Do something if success })
            .catch(error => {
                console.error(error);
                if (error.code === 'CERT_HAS_EXPIRED') {
                    // Certificate has expired
                }
                if (error.code === 'CERT_INVALID') {
                    // Certificate is invalid
                }
            });

Hope this helps someone else who comes across this thread!

about 4 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 Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!