3

With Javascript, we can determine if a connection is encrypted by checking location.protocol:

if ( 'https:' === location.protocol ) {
    // encrypted
} else {
    // plaintext / not encrypted
}

But is there a method to determine if the browser believes the connection is secure? I'm looking for a Javascript-programmatic version of when the URL bar shows green or red for an HTTPS connection that is secure or insecure:

Browser URL bar showing an encrypted but insecure connection

hunteke
  • 3,648
  • 1
  • 7
  • 17
Prozrachniy
  • 151
  • 8
  • https://stackoverflow.com/questions/2604399/is-there-a-way-to-get-ssl-certificate-details-using-javascript potentially useful but a very old thread. – Marty Nov 27 '17 at 07:21

1 Answers1

1

What you are looking for is the SSL certificate details that is available at the browser and it is not exposed to JavaScript.

So, unfortunately, none of the current versions of the browsers (if not all browsers, at least FireFox, IE/Edge and Chrome) make this certificate details accessible by JavaScript.

Muhammad Altabba
  • 2,583
  • 19
  • 31