title: Detect if webpage loaded using untrusted SSL certificate in javascript
body: <p>Is there a way to detect in JavaScript if the site was loaded over HTTPS using an SSL certificate untrusted by the browser (but accepted by the user)? I.e. it is invalid/expired/self-signed SSL certificate.</p>
  
  <p><code>window.isSecureContext</code> does not indicate this, it is <code>true</code> in all cases I tried on my own and on <a href="https://badssl.com" rel="nofollow noreferrer">badssl.com</a> if the page is loaded over HTTPS.</p>
  
  <p>My use case:  I am trying to use ApplicationCache but it refuses to work: on Chrome it fires the <code>error</code> callback with exception message <a href="https://stackoverflow.com/questions/28507846/manifest-fetch-failed-9">"Manifest fetch failed (9)"</a>, on Firefox it fails silently.</p>
  
  <p>As this means the browser behaves differently I hope it is detectable and I would like to make sure ApplicationCache is skipped altogether when it cannot be used.</p>
  
  <hr>
  
  <p>I'd not like to create a seperate SSL connection from a JavaScript (user might have certs of custom CAs installed, etc.), nor try-catch an exception with ApplicationCache.</p>