Commit Graph
93 Commits
Author SHA1 Message Date
Daniel Holbert 82882b1670 Bug 2043111: Use std::move in various AppendElement calls in security/. r=nss-reviewers,keeler
In each modified case, we can transfer an existing reference count from a
going-out-of-scope local variable, instead of incurring unnecessary refcount
traffic by AddRef()'ing when we append and then immediately Release()'ing when
the local variable goes out of scope.

Differential Revision: https://phabricator.services.mozilla.com/D302966
2026-05-28 21:20:35 +00:00
Daniel Holbert a0b8609dc7 Bug 2043111: Use MakeRefPtr to do allocation for various RefPtr variables in security/. r=nss-reviewers,jschanck
Differential Revision: https://phabricator.services.mozilla.com/D302965
2026-05-28 21:20:32 +00:00
Lars Eggert 8bd928e1a1 Bug 2033073 - Retry stale PSK resumptions when no early data was offered r=valentin,kershaw,keeler,necko-reviewers,nss-reviewers,jesup
The DECRYPT_ERROR_ALERT retry added in this bug only fires when
mEarlyDataWasAvailable is true. Servers that don't advertise
max_early_data_size (e.g. wptserve, many real-world servers) never
hit it, so a stale persisted session ticket surfaces as a fatal
"Secure Connection Failed" instead of being evicted and retried.

- Move PossibleZeroRTTRetryError() into the outer Close() restart
  condition so the retry path runs regardless of early-data state.
- Extend the alert list with illegal_parameter, handshake_failure,
  decode_error, internal_error, missing_extension, and others that
  PSK rejection can plausibly trigger. Cert-validation alerts stay
  excluded since they would fail identically on a fresh handshake.

Differential Revision: https://phabricator.services.mozilla.com/D297580
2026-05-03 13:25:55 +00:00
agoloman a0d381a6f9 Revert "Bug 2033073 - Retry stale PSK resumptions when no early data was offered r=valentin,kershaw,keeler,necko-reviewers,nss-reviewers,jesup" for causing build bustages @GetResumptionTokenPresent.
This reverts commit c9d74cd7f3.
2026-05-03 12:17:37 +00:00
Lars Eggert c9d74cd7f3 Bug 2033073 - Retry stale PSK resumptions when no early data was offered r=valentin,kershaw,keeler,necko-reviewers,nss-reviewers,jesup
The DECRYPT_ERROR_ALERT retry added in this bug only fires when
mEarlyDataWasAvailable is true. Servers that don't advertise
max_early_data_size (e.g. wptserve, many real-world servers) never
hit it, so a stale persisted session ticket surfaces as a fatal
"Secure Connection Failed" instead of being evicted and retried.

- Move PossibleZeroRTTRetryError() into the outer Close() restart
  condition so the retry path runs regardless of early-data state.
- Extend the alert list with illegal_parameter, handshake_failure,
  decode_error, internal_error, missing_extension, and others that
  PSK rejection can plausibly trigger. Cert-validation alerts stay
  excluded since they would fail identically on a fresh handshake.

Differential Revision: https://phabricator.services.mozilla.com/D297580
2026-05-03 06:45:23 +00:00
Serban Stanca 824e717c6a Revert "Bug 2033073 - Retry stale PSK resumptions when no early data was offered r=valentin,kershaw,necko-reviewers,jesup" for causing multiple failures.
This reverts commit efc00d82f6.
2026-05-01 16:23:48 +00:00
Lars Eggert efc00d82f6 Bug 2033073 - Retry stale PSK resumptions when no early data was offered r=valentin,kershaw,necko-reviewers,jesup
The DECRYPT_ERROR_ALERT retry added in this bug only fires when
mEarlyDataWasAvailable is true. Servers that don't advertise
max_early_data_size (e.g. wptserve, many real-world servers) never
hit it, so a stale persisted session ticket surfaces as a fatal
"Secure Connection Failed" instead of being evicted and retried.

- Move PossibleZeroRTTRetryError() into the outer Close() restart
  condition so the retry path runs regardless of early-data state.
- Extend the alert list with illegal_parameter, handshake_failure,
  decode_error, internal_error, missing_extension, and others that
  PSK rejection can plausibly trigger. Cert-validation alerts stay
  excluded since they would fail identically on a fresh handshake.

Differential Revision: https://phabricator.services.mozilla.com/D297580
2026-05-01 14:12:05 +00:00
Nika Layzell 5f0f9dd22a Bug 2020817 - Part 4: Annotate & clean up nsACString callers of BeginReading/Data, r=xpcom-reviewers,media-playback-reviewers,webrtc-reviewers,cookie-reviewers,profiler-reviewers,win-reviewers,dom-storage-reviewers,permissions-reviewers,toolkit-telemetry-reviewers-rotation,layout-reviewers,dom-worker-reviewers,gfx-reviewers,webgpu-reviewers,necko-reviewers,dom-core,smaug,handyman,emilio,pehrsons,kershaw,timhuang,edenchuang,padenot,bradwerth
This is a large number of largely mechanical changes. When possible, the code
was called to directly call `.get()` instead, performing the assertions
manually. In many places PromiseFlatCString() calls were added to dynamically
copy the strings into null terminated buffers if the string was not null
terminated.

Differential Revision: https://phabricator.services.mozilla.com/D286158
2026-03-25 08:23:04 +00:00
Sylvestre Ledru 5db00ce70c Bug 2023419 - Remove Emacs/Vim modelines from security/ r=emilio
replaced by .editorconfig
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D287866
2026-03-17 12:10:18 +00:00
Dana Keeler 71a99f8c27 Bug 1994034 - make TLS handshake certificates always available r=jschanck,necko-reviewers,extension-reviewers,kershaw,robwu,dom-worker-reviewers,edenchuang
This patch renames nsITransportSecurityInfo.failedCertChain to
handshakeCertificates and makes the property always available (after the
handshake has completed, that is).

Differential Revision: https://phabricator.services.mozilla.com/D268467
2025-10-21 17:05:01 +00:00
Cristina Horotan ea45be222f Revert "Bug 1994034 - make TLS handshake certificates always available r=jschanck,necko-reviewers,extension-reviewers,kershaw,robwu" for causing mochitest failures on test_cache_padding.html
This reverts commit ed038d6760.
2025-10-14 23:25:55 +00:00
Dana Keeler ed038d6760 Bug 1994034 - make TLS handshake certificates always available r=jschanck,necko-reviewers,extension-reviewers,kershaw,robwu
This patch renames nsITransportSecurityInfo.failedCertChain to
handshakeCertificates and makes the property always available (after the
handshake has completed, that is).

Differential Revision: https://phabricator.services.mozilla.com/D268467
2025-10-14 21:46:05 +00:00
Valentin Gosu 53aba3edf2 Bug 1983426 - Initialize UsedPrivateDNS in CommonSocketControl constructor r=keeler
The race here is caused by the fact that CommonSocketControl::mUsedPrivateDNS was
initialized to false in the constructor, and then set to
`SetUsedPrivateDNS(GetProviderFlags() & nsISocketProvider::USED_PRIVATE_DNS);`
in SetCertVerificationResult.

However, these flags don't change, so we can just initialize it in the constructor.

Differential Revision: https://phabricator.services.mozilla.com/D267401
2025-10-06 09:12:59 +00:00
Dana Keeler 5e3c261ad8 Bug 1486551 - turn cert revocation error pages into (non-overridable) certificate error pages r=jschanck,fluent-reviewers,webidl,bolsson,smaug
SEC_ERROR_REVOKED_CERTIFICATE is a certificate error, not a TLS protocol error.
This patch updates the categorization of this error while maintaining the
property that it cannot be overridden. This has the benefit of making it
possible to show more diagnostic information in the error page, which this
patch also adds.

Differential Revision: https://phabricator.services.mozilla.com/D239220
2025-02-27 22:12:46 +00:00
Dana Keeler 18dfb975cf Bug 1905955 - remove SharedSSLState r=jschanck
Differential Revision: https://phabricator.services.mozilla.com/D215533
2024-07-18 00:56:21 +00:00
Valentin Gosu c3dde813f4 Bug 1851294 - Add nsITLSSocketControl.asyncStartTLS r=jschanck,necko-reviewers,kershaw
Thunderbird uses nsITLSSocketControl.startTLS to drive the XMPP
connection, but since we started enforcing proper thread safety in
bug 1847260, it's asserting when called on the main thread.

This patch marks StartTLS and proxyStartTLS as [noscript] and adds
asyncStartTLS. This new method dispatches a runnable to the socket thread
to call startTLS, then resolves (or rejects with the nsresult as an arg)
on the main thread.

Differential Revision: https://phabricator.services.mozilla.com/D207692
2024-04-19 09:42:41 +00:00
Sylvestre Ledru b0fe72dee5 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-15 15:29:02 +00:00
Cristina Horotan 7388749830 Backed out 2 changesets (bug 1856795) for causing build bustage at BasicEvents.h CLOSED TREE
Backed out changeset 1d98b028923a (bug 1856795)
Backed out changeset eae2ac93e17c (bug 1856795)
2023-10-14 21:42:14 +03:00
Sylvestre Ledru 4a97019e39 Bug 1856795 - Remove redundant member init r=emilio
Done with:
./mach static-analysis check --checks="-*, readability-redundant-member-init" --fix .

https://clang.llvm.org/extra/clang-tidy/checks/readability/redundant-member-init.html

Differential Revision: https://phabricator.services.mozilla.com/D190002
2023-10-14 17:34:26 +00:00
Dana Keeler 63db05ab9d Bug 1401466 - make the client auth certificate selection dialog tab modal r=jschanck,necko-reviewers,bolsson,kershaw,valentin
Previously, the client authentication certificate selection dialog could show
up unexpectedly. Because it was modal, it would prevent user interaction with
the browser. It could even get in a state where the dialog couldn't be
interacted with, and neither could anything else, so the entire browser would
be locked and the user would have to quit and restart.

This patch associates a top-level outer content window ID (called "browserId"
in networking code) with each NSSSocketControl. When a peer asks for a client
authentication certificate, the NSSSocketControl can use the ID to find the
relevant tab and open a tab-modal dialog, which allows other browser UI to be
interacted with.

Some loads cannot be associated with browser tabs, and so the implementation
falls back to opening a window-modal dialog on the most recently active window.
This is still better than the previous implementation, since the dialog is
connected to a window rather than being its own separate dialog.

Differential Revision: https://phabricator.services.mozilla.com/D183775
2023-08-30 03:05:35 +00:00
Cosmin Sabou 816e584379 Backed out changeset 16c71fac6426 (bug 1401466) for causing SocketControl related fuzzing build bustages. CLOSED TREE 2023-08-30 00:37:21 +03:00
Dana Keeler 709eefb9c7 Bug 1401466 - make the client auth certificate selection dialog tab modal r=jschanck,necko-reviewers,bolsson,kershaw,valentin
Previously, the client authentication certificate selection dialog could show
up unexpectedly. Because it was modal, it would prevent user interaction with
the browser. It could even get in a state where the dialog couldn't be
interacted with, and neither could anything else, so the entire browser would
be locked and the user would have to quit and restart.

This patch associates a top-level outer content window ID (called "browserId"
in networking code) with each NSSSocketControl. When a peer asks for a client
authentication certificate, the NSSSocketControl can use the ID to find the
relevant tab and open a tab-modal dialog, which allows other browser UI to be
interacted with.

Some loads cannot be associated with browser tabs, and so the implementation
falls back to opening a window-modal dialog on the most recently active window.
This is still better than the previous implementation, since the dialog is
connected to a window rather than being its own separate dialog.

Differential Revision: https://phabricator.services.mozilla.com/D183775
2023-08-29 20:47:45 +00:00
Dana Keeler a3e92cf884 Bug 1847260 - use diagnostic assertions to validate nsITransportSecurityInfo refactoring r=jschanck
Differential Revision: https://phabricator.services.mozilla.com/D185581
2023-08-07 17:42:11 +00:00
Dana Keeler 94dc5b9ec4 Bug 1813618 - buffer client auth certificate selection UI for speculative connections r=valentin,jschanck,necko-reviewers,kershaw
When necko makes a speculative connection, the peer may ask for a client
authentication certificate. This patch makes it so that when this happens,
no certificate selection UI will be shown until the connection is claimed (as
in, it is no longer merely speculative).

Differential Revision: https://phabricator.services.mozilla.com/D175528
2023-04-18 17:52:49 +00:00
serge-sans-paille a5bc7d11e9 Bug 1820573 - Make security/ buildable outside of a unified build environment r=andi,keeler
Differential Revision: https://phabricator.services.mozilla.com/D171732
2023-03-15 07:30:36 +00:00
Dana Keeler a9bcca7130 Bug 1791633 - separate nsITLSSocketControl from nsITransportSecurityInfo r=necko-reviewers,kershaw,jschanck
Depends on D160311

Differential Revision: https://phabricator.services.mozilla.com/D160313
2022-11-16 16:37:29 +00:00
Dana Keeler 41b8e4ba29 Bug 1791633 - rename nsISSLSocketControl to nsITLSSocketControl and move it and nsITransportSecurityInfo to PSM r=necko-reviewers,kershaw
Depends on D160310

Differential Revision: https://phabricator.services.mozilla.com/D160311
2022-11-16 16:37:29 +00:00
Marian-Vasile Laza f986221d71 Backed out 3 changesets (bug 1791633) for causing bustages on TransportSecurityInfo.cpp. CLOSED TREE
Backed out changeset 23b864e14db0 (bug 1791633)
Backed out changeset 0bcba3375ec0 (bug 1791633)
Backed out changeset ab0ea0d68f5c (bug 1791633)
2022-11-15 23:51:58 +02:00
Dana Keeler f608ea9a59 Bug 1791633 - separate nsITLSSocketControl from nsITransportSecurityInfo r=necko-reviewers,kershaw,jschanck
Depends on D160311

Differential Revision: https://phabricator.services.mozilla.com/D160313
2022-11-15 20:03:29 +00:00
Dana Keeler a9d672e5f2 Bug 1791633 - rename nsISSLSocketControl to nsITLSSocketControl and move it and nsITransportSecurityInfo to PSM r=necko-reviewers,kershaw
Depends on D160310

Differential Revision: https://phabricator.services.mozilla.com/D160311
2022-11-15 20:03:29 +00:00
Butkovits Atila a9f1f1a451 Backed out 3 changesets (bug 1791633) for causing build bustages at nsHttpConnectionMgr.cpp:. CLOSED TREE
Backed out changeset ee9744982673 (bug 1791633)
Backed out changeset f5a4bfdaba40 (bug 1791633)
Backed out changeset f57131b9cfe2 (bug 1791633)
2022-11-15 08:07:16 +02:00
Dana Keeler 4f397cbfed Bug 1791633 - separate nsITLSSocketControl from nsITransportSecurityInfo r=necko-reviewers,kershaw,jschanck
Depends on D160311

Differential Revision: https://phabricator.services.mozilla.com/D160313
2022-11-15 05:34:40 +00:00
Dana Keeler 7ec4b8f2d7 Bug 1791633 - rename nsISSLSocketControl to nsITLSSocketControl and move it and nsITransportSecurityInfo to PSM r=necko-reviewers,kershaw
Depends on D160310

Differential Revision: https://phabricator.services.mozilla.com/D160311
2022-11-15 05:34:40 +00:00
Dana Keeler 4fd5811a06 Bug 1720118 - store certificate error override and failed certificate chain information in the TLS token cache r=kershaw,jschanck,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D158793
2022-10-12 23:54:11 +00:00
Cristian Tuns 745961989b Backed out 2 changesets (bug 1720118) for causing Hybrid bustages on nsHashtablesFwd.h CLOSED TREE
Backed out changeset af570580e2f7 (bug 1720118)
Backed out changeset 57b8a6400749 (bug 1720118)
2022-10-12 14:20:47 -04:00
Dana Keeler c36eb1de44 Bug 1720118 - store certificate error override and failed certificate chain information in the TLS token cache r=kershaw,jschanck,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D158793
2022-10-12 17:43:29 +00:00
Kershaw Chang ca724bf23e Bug 1720601 - Allow token cache to store more than one token per key, r=necko-reviewers,dragana
1. Allow to store more than one token per key.
2. Allow to use the token only once. The token will be removed after reading it.
3. Add a gtest.

Differential Revision: https://phabricator.services.mozilla.com/D153605
2022-10-06 12:56:01 +00:00
Andreea Pavel 1a2f9764a5 Backed out 2 changesets (bug 1768250, bug 1720601) for multiple failures CLOSED TREE
Backed out changeset d6caea480d4d (bug 1768250)
Backed out changeset 97eccf466bf3 (bug 1720601)
2022-09-20 16:50:29 +03:00
Kershaw Chang 9358b395fe Bug 1720601 - Allow token cache to store more than one token per key, r=necko-reviewers,dragana
1. Allow to store more than one token per key.
2. Allow to use the token only once. The token will be removed after reading it.
3. Add a gtest.

Differential Revision: https://phabricator.services.mozilla.com/D153605
2022-09-20 12:58:06 +00:00
Dana Keeler 49f7067daa Bug 1770869 - remove nsISSLSocketControl.clientCert r=jschanck,necko-reviewers,kershaw
This field isn't used any longer and removing it will make future changes
eaiser.

Differential Revision: https://phabricator.services.mozilla.com/D147227
2022-06-01 23:20:58 +00:00
Butkovits Atila 22b3e62b6b Backed out 3 changesets (bug 1770869) for causing xpcshell failures at test_tls_server.js. CLOSED TREE
Backed out changeset 5c95392b800d (bug 1770869)
Backed out changeset 149d04a209b6 (bug 1770869)
Backed out changeset 5a138d047be1 (bug 1770869)
2022-06-02 00:18:26 +03:00
Dana Keeler 3037f1e5e1 Bug 1770869 - remove nsISSLSocketControl.clientCert r=jschanck,necko-reviewers,kershaw
This field isn't used any longer and removing it will make future changes
eaiser.

Differential Revision: https://phabricator.services.mozilla.com/D147227
2022-06-01 20:00:57 +00:00
John Schanck 0c61dbd6f9 Bug 1691122 - Remove subject common name fallback support in CertVerifier. r=keeler,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D143808
2022-04-28 19:48:06 +00:00
Butkovits Atila fa1c9023a9 Backed out changeset 0599b2a0913a (bug 1691122) for causing failures at test_peerConnection_basicAudioNATRelayTLS.html. CLOSED TREE 2022-04-28 03:58:05 +03:00
John Schanck cf55523d7a Bug 1691122 - Remove subject common name fallback support in CertVerifier. r=keeler,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D143808
2022-04-27 20:57:31 +00:00
Dana Keeler 9df58d0af0 Bug 1751078 - prefer nsIX509Cert over the concrete class r=necko-reviewers,jschanck,kershaw
This patch updates some uses of RefPtr<nsNSSCertificate> to
nsCOMPtr<nsIX509Cert> because it's not necessary to use the concrete class.
This patch also removes some empty files that should have been removed in a
previous bug.

Differential Revision: https://phabricator.services.mozilla.com/D136679
2022-01-26 21:23:50 +00:00
Dana Keeler 20d36bcf17 Bug 1750089 - remove some unnecessary uses of nsIX509Cert::GetCert() r=jschanck
nsIX509Cert::GetCert() may cause a CERTCertificate to be instantiated. Doing so
can have performance and stability implications, so it's best to avoid it.
This patch avoids it where possible.

Differential Revision: https://phabricator.services.mozilla.com/D135945
2022-01-19 21:24:47 +00:00
Iulian Moraru 4065e86f26 Backed out 2 changesets (bug 1750089) for causing mochitest failures on browser_webconsole_certificate_messages.js.
Backed out changeset 7ebb345a9293 (bug 1750089)
Backed out changeset 40bd1975208d (bug 1750089)
2022-01-19 04:07:44 +02:00
Dana Keeler c251944c26 Bug 1750089 - remove some unnecessary uses of nsIX509Cert::GetCert() r=jschanck
nsIX509Cert::GetCert() may cause a CERTCertificate to be instantiated. Doing so
can have performance and stability implications, so it's best to avoid it.
This patch avoids it where possible.

Depends on D135943

Differential Revision: https://phabricator.services.mozilla.com/D135945
2022-01-18 23:54:12 +00:00
Dana Keeler c314e2625a Bug 1748341 - remove superfluous nsNSSCertificate "constructors" r=necko-reviewers,kershaw,jschanck
nsNSSCertificate had a few functions that acted as constructors. This patch
removes these unnecessary functions and uses actual constructors.

Depends on D134977

Differential Revision: https://phabricator.services.mozilla.com/D134978
2022-01-13 22:10:51 +00:00