Reputation: 151
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:
Upvotes: 3
Views: 362
Reputation: 2728
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.
Upvotes: 1