Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 9aec9e0

Browse files
authored
Background JS Cleanup: Move SSL Codes (#20094)
* Background JS Cleanup: Move SSL Codes * Remove console log * Fix lint errors
1 parent e500450 commit 9aec9e0

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

chromium/background-scripts/background.js

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const rules = require('./rules'),
99
update = require('./update'),
1010
{ update_channels } = require('./update_channels'),
1111
wasm = require('./wasm'),
12-
ipUtils = require('./ip_utils');
13-
12+
ipUtils = require('./ip_utils'),
13+
ssl_codes = require('./ssl_codes');
1414

1515
let all_rules = new rules.RuleSets();
1616
let blooms = [];
@@ -579,28 +579,9 @@ function onErrorOccurred(details) {
579579
if (httpNowhereOn &&
580580
details.type == "main_frame" &&
581581
browserSession.getRequest(details.requestId, "simple_http_nowhere_redirect", false) &&
582-
( // Enumerate a class of errors that are likely due to HTTPS misconfigurations
583-
details.error.indexOf("net::ERR_SSL_") == 0 ||
584-
details.error.indexOf("net::ERR_CERT_") == 0 ||
585-
details.error.indexOf("net::ERR_CONNECTION_") == 0 ||
586-
details.error.indexOf("net::ERR_ABORTED") == 0 ||
587-
details.error.indexOf("net::ERR_SSL_PROTOCOL_ERROR") == 0 ||
588-
details.error.indexOf("NS_ERROR_CONNECTION_REFUSED") == 0 ||
589-
details.error.indexOf("NS_ERROR_NET_TIMEOUT") == 0 ||
590-
details.error.indexOf("NS_ERROR_NET_ON_TLS_HANDSHAKE_ENDED") == 0 ||
591-
details.error.indexOf("SSL received a record that exceeded the maximum permissible length.") == 0 ||
592-
details.error.indexOf("Peer’s Certificate has expired.") == 0 ||
593-
details.error.indexOf("Unable to communicate securely with peer: requested domain name does not match the server’s certificate.") == 0 ||
594-
details.error.indexOf("Peer’s Certificate issuer is not recognized.") == 0 ||
595-
details.error.indexOf("Peer’s Certificate has been revoked.") == 0 ||
596-
details.error.indexOf("Peer reports it experienced an internal error.") == 0 ||
597-
details.error.indexOf("The server uses key pinning (HPKP) but no trusted certificate chain could be constructed that matches the pinset. Key pinning violations cannot be overridden.") == 0 ||
598-
details.error.indexOf("SSL received a weak ephemeral Diffie-Hellman key in Server Key Exchange handshake message.") == 0 ||
599-
details.error.indexOf("The certificate was signed using a signature algorithm that is disabled because it is not secure.") == 0 ||
600-
details.error.indexOf("Unable to communicate securely with peer: requested domain name does not match the server’s certificate.") == 0 ||
601-
details.error.indexOf("Cannot communicate securely with peer: no common encryption algorithm(s).") == 0 ||
602-
details.error.indexOf("SSL peer has no certificate for the requested DNS name.") == 0
603-
)) {
582+
// Enumerate errors that are likely due to HTTPS misconfigurations
583+
ssl_codes.error_list.some(message => details.error.includes(message))
584+
) {
604585
let url = new URL(details.url);
605586
if (url.protocol == "https:") {
606587
url.protocol = "http:";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
"use strict";
2+
3+
/**
4+
* @exports error_list
5+
* @type {array}
6+
* @description A list of known SSL config errors to filter through and not try to upgrade the user
7+
* @see
8+
* Chrome SSL errors: https://github.com/chromium/chromium/blob/master/components/domain_reliability/util.cc
9+
* Firefox SSL Errors: https://hg.mozilla.org/releases/mozilla-release/file/tip/security/manager/locales/en-US/chrome/pipnss/nsserrors.properties
10+
*/
11+
12+
(function (exports) {
13+
14+
const error_list = [
15+
"net::ERR_SSL_PROTOCOL_ERROR",
16+
"net::ERR_SSL_VERSION_OR_CIPHER_MISMATCH",
17+
"net::ERR_SSL_UNRECOGNIZED_NAME_ALERT",
18+
"net::ERR_SSL_PINNED_KEY_NOT_IN_CERT_CHAIN",
19+
"net::ERR_CERT_COMMON_NAME_INVALID",
20+
"net::ERR_CERT_DATE_INVALID",
21+
"net::ERR_CERT_AUTHORITY_INVALID",
22+
"net::ERR_CERT_REVOKED",
23+
"net::ERR_CERT_INVALID",
24+
"net::ERR_CONNECTION_CLOSED",
25+
"net::ERR_CONNECTION_RESET",
26+
"net::ERR_CONNECTION_REFUSED",
27+
"net::ERR_CONNECTION_ABORTED",
28+
"net::ERR_CONNECTION_FAILED",
29+
"net::ERR_ABORTED", ,
30+
"NS_ERROR_CONNECTION_REFUSED",
31+
"NS_ERROR_NET_ON_TLS_HANDSHAKE_ENDED",
32+
"NS_BINDING_ABORTED",
33+
"SSL received a record that exceeded the maximum permissible length.",
34+
"Peer’s Certificate has expired.",
35+
"Unable to communicate securely with peer: requested domain name does not match the server’s certificate.",
36+
"Peer’s Certificate issuer is not recognized.",
37+
"Peer’s Certificate has been revoked.",
38+
"Peer reports it experienced an internal error.",
39+
"The server uses key pinning (HPKP) but no trusted certificate chain could be constructed that matches the pinset. Key pinning violations cannot be overridden.",
40+
"SSL received a weak ephemeral Diffie-Hellman key in Server Key Exchange handshake message.",
41+
"The certificate was signed using a signature algorithm that is disabled because it is not secure.",
42+
"Cannot communicate securely with peer: no common encryption algorithm(s).",
43+
"SSL peer has no certificate for the requested DNS name."
44+
];
45+
46+
Object.assign(exports, { error_list });
47+
48+
})(typeof exports !== 'undefined' ? exports : require.scopes.ssl_codes = {});

chromium/manifest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"external/pako-1.0.5/pako_inflate.min.js",
2020
"background-scripts/incognito.js",
2121
"background-scripts/ip_utils.js",
22+
"background-scripts/modules/ssl_codes.js",
2223
"background-scripts/background.js"
2324
]
2425
},

0 commit comments

Comments
 (0)