diff --git a/app/extensions/brave/content/scripts/brave-about.js b/app/extensions/brave/content/scripts/brave-about.js index 5532de728a3..103d690db43 100644 --- a/app/extensions/brave/content/scripts/brave-about.js +++ b/app/extensions/brave/content/scripts/brave-about.js @@ -70,6 +70,12 @@ }) window.dispatchEvent(event) }) + ipcRenderer.on('set-cert-error-detail', (e, details) => { + const event = new window.CustomEvent('set-cert-error-detail', { + detail: details + }) + window.dispatchEvent(event) + }) window.addEventListener('dispatch-action', (e) => { ipcRenderer.send('dispatch-action', e.detail) @@ -83,6 +89,9 @@ window.addEventListener('cert-error-accepted', (e) => { ipcRenderer.send('cert-error-accepted', e.detail.url) }) + window.addEventListener('get-cert-error-detail', (e) => { + ipcRenderer.send('get-cert-error-detail', e.detail.url) + }) window.addEventListener('new-frame', (e) => { ipcRenderer.sendToHost('new-frame', e.detail.frameOpts, e.detail.openInForeground) }) diff --git a/app/extensions/brave/locales/en-US/app.properties b/app/extensions/brave/locales/en-US/app.properties index 376cd7695e8..4bf3c7b3a18 100644 --- a/app/extensions/brave/locales/en-US/app.properties +++ b/app/extensions/brave/locales/en-US/app.properties @@ -25,6 +25,7 @@ certErrorText=This site cannot be loaded due to a certificate error: certErrorAdvanced=Advanced settings certErrorSafety=Back to safety certErrorButtonText=Ignore certificate error (dangerous!) +certErrorShowCertificate=Show Certificate safebrowsingError=Dangerous Site Blocked safebrowsingErrorText=For your safety, Brave has blocked this site because it is distributing malware or stealing login credentials. safebrowsingErrorAdvanced=Advanced diff --git a/app/index.js b/app/index.js index 1ff7e4539c8..5eb719f835f 100644 --- a/app/index.js +++ b/app/index.js @@ -55,6 +55,7 @@ let lastWindowClosed = false // Domains to accept bad certs for. TODO: Save the accepted cert fingerprints. let acceptCertDomains = {} +let errorCerts = {} // URLs to callback for auth. let authCallbacks = {} // Don't show the keytar prompt more than once per 24 hours @@ -208,6 +209,8 @@ app.on('ready', () => { return } + errorCerts[url] = cert + // Tell the page to show an unlocked icon. Note this is sent to the main // window webcontents, not the webview webcontents let sender = webContents.hostWebContents || webContents @@ -450,6 +453,12 @@ app.on('ready', () => { } }) + ipcMain.on(messages.GET_CERT_ERROR_DETAIL, (event, url) => { + event.sender.send(messages.SET_CERT_ERROR_DETAIL, { + cert: errorCerts[url] + }) + }) + // save app state every 5 minutes regardless of update frequency setInterval(initiateSessionStateSave, 1000 * 60 * 5) AppStore.addChangeListener(() => { diff --git a/js/about/aboutActions.js b/js/about/aboutActions.js index 3ece6a6a0af..aead0b61d96 100644 --- a/js/about/aboutActions.js +++ b/js/about/aboutActions.js @@ -101,6 +101,20 @@ const AboutActions = { window.dispatchEvent(event) }, + /** + * Get certificate detail when error. + * + * @param {string} url - The URL with the cert error + */ + getCertErrorDetail: function (url) { + const event = new window.CustomEvent(messages.GET_CERT_ERROR_DETAIL, { + detail: { + url + } + }) + window.dispatchEvent(event) + }, + /** * Opens a context menu */ diff --git a/js/about/certerror.js b/js/about/certerror.js index 5793edc59ea..014c4eeaec4 100644 --- a/js/about/certerror.js +++ b/js/about/certerror.js @@ -15,8 +15,11 @@ class CertErrorPage extends React.Component { constructor () { super() this.state = { - advanced: false + advanced: false, + cert: null } + this.onSetCertErrorDetail = this.onSetCertErrorDetail.bind(this) + window.addEventListener('set-cert-error-detail', this.onSetCertErrorDetail) } onAccept () { @@ -40,6 +43,17 @@ class CertErrorPage extends React.Component { this.setState({advanced: true}) } + onDetail () { + aboutActions.getCertErrorDetail(this.state.url) + } + + onSetCertErrorDetail (e) { + e.stopPropagation() + this.setState({ + cert: e.detail.cert + }) + } + render () { return
@@ -49,12 +63,30 @@ class CertErrorPage extends React.Component {   {this.state.url || ''} {this.state.error || ''} + {this.state.cert + ? (
+ {'Issued To'} + {'Common Name (CN): '} + {'Organization (O): '} + {'Organization Unit(OU): '} + {'Serial Number: '} + {'Issued By'} + {'Common Name (CN): ' + this.state.cert.issuerName} + {'Organization (O): '} + {'Organization Unit(OU): '} + {'Period of Validity'} + {'Begins On: '} + {'Expires On: '} +
) : null}
) + :