From 13552d57d1b8ac63e2b0e4d2c75afb79d5985cbd Mon Sep 17 00:00:00 2001 From: Roy Tam Date: Fri, 28 Feb 2020 13:30:16 +0800 Subject: [PATCH] reverted my TLS 1.3 changes and import changes from tenfourfox: - #334, closes #489: enable TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 for amtrak.com (14d8add7c) (#334 part only) - #590: TLS 1.3 support (consolidated) with locale workaround (fae264c81) --- devtools/shared/webconsole/network-helper.js | 2 +- media/mtransport/transportlayerdtls.cpp | 2 +- netwerk/base/security-prefs.js | 2 +- netwerk/protocol/http/nsHttpConnection.cpp | 6 +++++- netwerk/test/unit/test_tls_server.js | 8 +------- security/manager/ssl/nsNSSCallbacks.cpp | 11 +++++++++++ security/manager/ssl/nsNSSComponent.cpp | 15 +++++++-------- security/manager/ssl/nsNSSIOLayer.cpp | 5 ++++- toolkit/components/telemetry/Histograms.json | 18 ++++++++++++------ uriloader/base/nsDocLoader.cpp | 10 +++++++++- 10 files changed, 52 insertions(+), 27 deletions(-) diff --git a/devtools/shared/webconsole/network-helper.js b/devtools/shared/webconsole/network-helper.js index ac0df7a7e..6159d91af 100644 --- a/devtools/shared/webconsole/network-helper.js +++ b/devtools/shared/webconsole/network-helper.js @@ -529,7 +529,7 @@ var NetworkHelper = { * If state == broken: * - errorMessage: full error message from nsITransportSecurityInfo. * If state == secure: - * - protocolVersion: one of TLSv1, TLSv1.1, TLSv1.2. + * - protocolVersion: one of TLSv1, TLSv1.1, TLSv1.2, TLSv1.3. * - cipherSuite: the cipher suite used in this connection. * - cert: information about certificate used in this connection. * See parseCertificateInfo for the contents. diff --git a/media/mtransport/transportlayerdtls.cpp b/media/mtransport/transportlayerdtls.cpp index 5681eac1d..8a1c8e738 100644 --- a/media/mtransport/transportlayerdtls.cpp +++ b/media/mtransport/transportlayerdtls.cpp @@ -691,6 +691,7 @@ static const uint32_t EnabledCiphers[] = { static const uint32_t DisabledCiphers[] = { // ALL SHA384 ciphers are disabled per bug 1310061. TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, @@ -711,7 +712,6 @@ static const uint32_t DisabledCiphers[] = { TLS_ECDH_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, - TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, diff --git a/netwerk/base/security-prefs.js b/netwerk/base/security-prefs.js index d527f3644..32c3be090 100644 --- a/netwerk/base/security-prefs.js +++ b/netwerk/base/security-prefs.js @@ -7,7 +7,7 @@ pref("security.tls.version.max", 4); pref("security.tls.version.fallback-limit", 3); pref("security.tls.insecure_fallback_hosts", ""); pref("security.tls.unrestricted_rc4_fallback", false); -pref("security.tls.enable_0rtt_data", false); +pref("security.tls.enable_0rtt_data", true); pref("security.ssl.treat_unsafe_negotiation_as_broken", false); pref("security.ssl.require_safe_negotiation", false); diff --git a/netwerk/protocol/http/nsHttpConnection.cpp b/netwerk/protocol/http/nsHttpConnection.cpp index 7ba3cdb04..31229a82d 100644 --- a/netwerk/protocol/http/nsHttpConnection.cpp +++ b/netwerk/protocol/http/nsHttpConnection.cpp @@ -99,18 +99,22 @@ nsHttpConnection::~nsHttpConnection() if (!mEverUsedSpdy) { LOG(("nsHttpConnection %p performed %d HTTP/1.x transactions\n", this, mHttp1xTransactionCount)); +/* Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_CONN, mHttp1xTransactionCount); +*/ } if (mTotalBytesRead) { uint32_t totalKBRead = static_cast(mTotalBytesRead >> 10); LOG(("nsHttpConnection %p read %dkb on connection spdy=%d\n", this, totalKBRead, mEverUsedSpdy)); +/* Telemetry::Accumulate(mEverUsedSpdy ? Telemetry::SPDY_KBREAD_PER_CONN : Telemetry::HTTP_KBREAD_PER_CONN, totalKBRead); +*/ } if (mForceSendTimer) { mForceSendTimer->Cancel(); @@ -414,7 +418,7 @@ nsHttpConnection::EnsureNPNComplete(nsresult &aOut0RTTWriteHandshakeValue, mContentBytesWritten = mContentBytesWritten0RTT; } - Telemetry::Accumulate(Telemetry::SPDY_NPN_CONNECT, UsingSpdy()); + //Telemetry::Accumulate(Telemetry::SPDY_NPN_CONNECT, UsingSpdy()); } npnComplete: diff --git a/netwerk/test/unit/test_tls_server.js b/netwerk/test/unit/test_tls_server.js index 38bc13a9a..528062730 100644 --- a/netwerk/test/unit/test_tls_server.js +++ b/netwerk/test/unit/test_tls_server.js @@ -66,13 +66,7 @@ function startServer(cert, expectingPeerCert, clientCertificateConfig) { equal(status.tlsVersionUsed, Ci.nsITLSClientStatus.TLS_VERSION_1_2, "Using TLS 1.2"); - let expectedCipher; - if (expectedVersion >= 772) { - expectedCipher = "TLS_AES_128_GCM_SHA256"; - } else { - expectedCipher = "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"; - } - equal(status.cipherName, expectedCipher, + equal(status.cipherName, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "Using expected cipher"); equal(status.keyLength, 128, "Using 128-bit key"); equal(status.macLength, 128, "Using 128-bit MAC"); diff --git a/security/manager/ssl/nsNSSCallbacks.cpp b/security/manager/ssl/nsNSSCallbacks.cpp index 7d4622808..d0bba6aec 100644 --- a/security/manager/ssl/nsNSSCallbacks.cpp +++ b/security/manager/ssl/nsNSSCallbacks.cpp @@ -30,8 +30,10 @@ using namespace mozilla::psm; extern PRLogModuleInfo* gPIPNSSLog; +#if (0) // TenFourFox issue 334 static void AccumulateCipherSuite(Telemetry::ID probe, const SSLChannelInfo& channelInfo); +#endif namespace { @@ -1030,6 +1032,8 @@ CanFalseStartCallback(PRFileDesc* fd, void* client_data, PRBool *canFalseStart) return SECSuccess; } +#if(0) // TenFourFox issue 334 +#error this no longer has correct constants and should not be reenabled static void AccumulateNonECCKeySize(Telemetry::ID probe, uint32_t bits) { @@ -1121,6 +1125,7 @@ AccumulateCipherSuite(Telemetry::ID probe, const SSLChannelInfo& channelInfo) MOZ_ASSERT(value != 0); Telemetry::Accumulate(probe, value); } +#endif void HandshakeCallback(PRFileDesc* fd, void* client_data) { nsNSSShutDownPreventionLock locker; @@ -1153,6 +1158,7 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { rv = SSL_GetChannelInfo(fd, &channelInfo, sizeof(channelInfo)); MOZ_ASSERT(rv == SECSuccess); if (rv == SECSuccess) { +#if(0) // TenFourFox issue 334 // Get the protocol version for telemetry // 0=ssl3, 1=tls1, 2=tls1.1, 3=tls1.2, 4=tls1.3 unsigned int versionEnum = channelInfo.protocolVersion & 0xFF; @@ -1162,6 +1168,7 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { infoObject->IsFullHandshake() ? Telemetry::SSL_CIPHER_SUITE_FULL : Telemetry::SSL_CIPHER_SUITE_RESUMED, channelInfo); +#endif SSLCipherSuiteInfo cipherInfo; rv = SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo, @@ -1170,17 +1177,20 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { if (rv == SECSuccess) { usesWeakCipher = cipherInfo.symCipher == ssl_calg_rc4; +#if(0) // keyExchange null=0, rsa=1, dh=2, fortezza=3, ecdh=4 Telemetry::Accumulate( infoObject->IsFullHandshake() ? Telemetry::SSL_KEY_EXCHANGE_ALGORITHM_FULL : Telemetry::SSL_KEY_EXCHANGE_ALGORITHM_RESUMED, channelInfo.keaType); +#endif DebugOnly KEAUsed; MOZ_ASSERT(NS_SUCCEEDED(infoObject->GetKEAUsed(&KEAUsed)) && (KEAUsed == channelInfo.keaType)); +#if(0) if (infoObject->IsFullHandshake()) { switch (channelInfo.keaType) { case ssl_kea_rsa: @@ -1231,6 +1241,7 @@ void HandshakeCallback(PRFileDesc* fd, void* client_data) { ? Telemetry::SSL_SYMMETRIC_CIPHER_FULL : Telemetry::SSL_SYMMETRIC_CIPHER_RESUMED, cipherInfo.symCipher); +#endif } } diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index d6d3c72c7..678b0b6bd 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -644,6 +644,13 @@ static const CipherPref sCipherPrefs[] = { { "security.ssl3.dhe_rsa_aes_256_sha", TLS_DHE_RSA_WITH_AES_256_CBC_SHA, true }, + { "security.tls13.aes_128_gcm_sha256", + TLS_AES_128_GCM_SHA256, true }, + { "security.tls13.chacha20_poly1305_sha256", + TLS_CHACHA20_POLY1305_SHA256, true }, + { "security.tls13.aes_256_gcm_sha384", + TLS_AES_256_GCM_SHA384, true }, + { "security.ssl3.ecdhe_rsa_rc4_128_sha", TLS_ECDHE_RSA_WITH_RC4_128_SHA, true, true }, // deprecated (RC4) { "security.ssl3.ecdhe_ecdsa_rc4_128_sha", @@ -661,13 +668,6 @@ static const CipherPref sCipherPrefs[] = { { "security.ssl3.rsa_rc4_128_md5", TLS_RSA_WITH_RC4_128_MD5, true, true }, // deprecated (RSA key exchange, RC4, HMAC-MD5) - { "security.tls13.aes_128_gcm_sha256", - TLS_AES_128_GCM_SHA256, true }, - { "security.tls13.chacha20_poly1305_sha256", - TLS_CHACHA20_POLY1305_SHA256, true }, - { "security.tls13.aes_256_gcm_sha384", - TLS_AES_256_GCM_SHA384, true }, - // All the rest are disabled by default { nullptr, 0 } // end marker @@ -1097,7 +1097,6 @@ nsNSSComponent::InitializeNSS() SSL_OptionSetDefault(SSL_ENABLE_ALPN, Preferences::GetBool("security.ssl.enable_alpn", ALPN_ENABLED_DEFAULT)); - SSL_OptionSetDefault(SSL_ENABLE_0RTT_DATA, Preferences::GetBool("security.tls.enable_0rtt_data", ENABLED_0RTT_DATA_DEFAULT)); diff --git a/security/manager/ssl/nsNSSIOLayer.cpp b/security/manager/ssl/nsNSSIOLayer.cpp index 4d620fb7b..dec57b1bd 100644 --- a/security/manager/ssl/nsNSSIOLayer.cpp +++ b/security/manager/ssl/nsNSSIOLayer.cpp @@ -1069,6 +1069,7 @@ class SSLErrorRunnable : public SyncRunnableBase namespace { +#if(0) uint32_t tlsIntoleranceTelemetryBucket(PRErrorCode err) { // returns a numeric code for where we track various errors in telemetry @@ -1091,6 +1092,7 @@ uint32_t tlsIntoleranceTelemetryBucket(PRErrorCode err) default: return 0; } } +#endif bool retryDueToTLSIntolerance(PRErrorCode err, nsNSSSocketInfo* socketInfo) @@ -1166,12 +1168,13 @@ retryDueToTLSIntolerance(PRErrorCode err, nsNSSSocketInfo* socketInfo) return false; } +#if(0) +#error doesn't support TLS 1.3 uint32_t reason = tlsIntoleranceTelemetryBucket(err); if (reason == 0) { return false; } -#if(0) Telemetry::ID pre; Telemetry::ID post; switch (range.max) { diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 3084d70b5..2e981296b 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -8083,37 +8083,37 @@ "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.2 intolerance, before considering historical info" + "description": "detected symptom of TLS 1.2 intolerance, before considering historical info" }, "SSL_TLS12_INTOLERANCE_REASON_POST": { "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.2 intolerance, after considering historical info" + "description": "detected symptom of TLS 1.2 intolerance, after considering historical info" }, "SSL_TLS11_INTOLERANCE_REASON_PRE": { "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.1 intolerance, before considering historical info" + "description": "detected symptom of TLS 1.1 intolerance, before considering historical info" }, "SSL_TLS11_INTOLERANCE_REASON_POST": { "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.1 intolerance, after considering historical info" + "description": "detected symptom of TLS 1.1 intolerance, after considering historical info" }, "SSL_TLS10_INTOLERANCE_REASON_PRE": { "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.0 intolerance, before considering historical info" + "description": "detected symptom of TLS 1.0 intolerance, before considering historical info" }, "SSL_TLS10_INTOLERANCE_REASON_POST": { "expires_in_version": "never", "kind": "enumerated", "n_values": 64, - "description": "Detected symptom of TLS 1.0 intolerance, after considering historical info" + "description": "detected symptom of TLS 1.0 intolerance, after considering historical info" }, "SSL_VERSION_FALLBACK_INAPPROPRIATE": { "expires_in_version": "never", @@ -8121,6 +8121,12 @@ "n_values": 64, "description": "TLS/SSL version intolerance was falsely detected, server rejected handshake" }, + "SSL_FALLBACK_LIMIT_REACHED": { + "expires_in_version": "default", + "kind": "enumerated", + "n_values": 16, + "description": "TLS/SSL version fallback reached the minimum version (1=TLS 1.0, 2=TLS 1.1, 3=TLS 1.2) or the fallback limit (4=TLS 1.0, 8=TLS 1.1, 12=TLS 1.2), stopped the fallback" + }, "SSL_WEAK_CIPHERS_FALLBACK": { "expires_in_version": "never", "kind": "enumerated", diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 6f8af253a..8059e0155 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -1090,7 +1090,15 @@ NS_IMETHODIMP nsDocLoader::OnStatus(nsIRequest* aRequest, nsISupports* ctxt, if (!sbs) return NS_ERROR_FAILURE; nsXPIDLString msg; - nsresult rv = sbs->FormatStatusMessage(aStatus, aStatusArg, + /* TenFourFox issue 590. Map NS_NET_STATUS_TLS_HANDSHAKE_STARTING and + NS_NET_STATUS_TLS_HANDSHAKE_ENDED to NS_NET_STATUS_CONNECTED_TO so + that we don't instantly invalidate all our locales. See also + netwerk/locales/en-US/necko.properties XXX */ + nsresult rv = sbs->FormatStatusMessage( + (aStatus == NS_NET_STATUS_TLS_HANDSHAKE_STARTING || + aStatus == NS_NET_STATUS_TLS_HANDSHAKE_ENDED) ? + NS_NET_STATUS_CONNECTED_TO : aStatus, + aStatusArg, getter_Copies(msg)); if (NS_FAILED(rv)) return rv;