Skip to content

Commit

Permalink
Bug 1781104 - remove unnecessary bits parameter from nsICertOverrideS…
Browse files Browse the repository at this point in the history
…ervice r=djackson,necko-reviewers,geckoview-reviewers,extension-reviewers,kershaw,calu

Differential Revision: https://phabricator.services.mozilla.com/D152826
  • Loading branch information
mozkeeler committed Aug 26, 2022
1 parent 40cd3d5 commit b4c45d4
Show file tree
Hide file tree
Showing 43 changed files with 270 additions and 1,218 deletions.
1 change: 0 additions & 1 deletion browser/base/content/test/about/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ support-files =
[browser_aboutCertError_clockSkew.js]
[browser_aboutCertError_exception.js]
[browser_aboutCertError_mitm.js]
[browser_aboutCertError_multiple_errors.js]
[browser_aboutCertError_noSubjectAltName.js]
[browser_aboutCertError_offlineSupport.js]
[browser_aboutCertError_telemetry.js]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ add_task(async function checkPermanentExceptionPref() {
-1,
{},
cert,
{},
isTemporary
);
ok(hasException, "Has stored an exception for the page.");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,11 @@ add_task(async function() {
let cert = getTestServerCertificate();
// Start a server and trust its certificate.
let server = startServer(cert);
let overrideBits =
Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(
"localhost",
server.port,
{},
cert,
overrideBits,
true
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,11 @@ add_task(async function() {
let cert = getTestServerCertificate();
// Start the proxy and configure Firefox to trust its certificate.
let server = startServer(cert);
let overrideBits =
Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(
"localhost",
server.port,
{},
cert,
overrideBits,
true
);
// Configure Firefox to use the proxy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ add_setup(async function() {
},
]);

let overrideBits =
Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(
"localhost",
server.port,
{},
cert,
overrideBits,
true
);

Expand Down
37 changes: 2 additions & 35 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,27 +1572,6 @@ already_AddRefed<mozilla::dom::Promise> Document::AddCertException(
return promise.forget();
}

bool isUntrusted = true;
rv = tsi->GetIsUntrusted(&isUntrusted);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();
}

bool isDomainMismatch = true;
rv = tsi->GetIsDomainMismatch(&isDomainMismatch);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();
}

bool isNotValidAtThisTime = true;
rv = tsi->GetIsNotValidAtThisTime(&isNotValidAtThisTime);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();
}

nsCOMPtr<nsIX509Cert> cert;
rv = tsi->GetServerCert(getter_AddRefs(cert));
if (NS_WARN_IF(NS_FAILED(rv))) {
Expand All @@ -1604,17 +1583,6 @@ already_AddRefed<mozilla::dom::Promise> Document::AddCertException(
return promise.forget();
}

uint32_t flags = 0;
if (isUntrusted) {
flags |= nsICertOverrideService::ERROR_UNTRUSTED;
}
if (isDomainMismatch) {
flags |= nsICertOverrideService::ERROR_MISMATCH;
}
if (isNotValidAtThisTime) {
flags |= nsICertOverrideService::ERROR_TIME;
}

if (XRE_IsContentProcess()) {
nsCOMPtr<nsISerializable> certSer = do_QueryInterface(cert);
nsCString certSerialized;
Expand All @@ -1623,8 +1591,7 @@ already_AddRefed<mozilla::dom::Promise> Document::AddCertException(
ContentChild* cc = ContentChild::GetSingleton();
MOZ_ASSERT(cc);
OriginAttributes const& attrs = NodePrincipal()->OriginAttributesRef();
cc->SendAddCertException(certSerialized, flags, host, port, attrs,
aIsTemporary)
cc->SendAddCertException(certSerialized, host, port, attrs, aIsTemporary)
->Then(GetCurrentSerialEventTarget(), __func__,
[promise](const mozilla::MozPromise<
nsresult, mozilla::ipc::ResponseRejectReason,
Expand All @@ -1648,7 +1615,7 @@ already_AddRefed<mozilla::dom::Promise> Document::AddCertException(

OriginAttributes const& attrs = NodePrincipal()->OriginAttributesRef();
rv = overrideService->RememberValidityOverride(host, port, attrs, cert,
flags, aIsTemporary);
aIsTemporary);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(rv);
return promise.forget();
Expand Down
7 changes: 3 additions & 4 deletions dom/ipc/ContentParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6547,9 +6547,8 @@ mozilla::ipc::IPCResult ContentParent::RecvBHRThreadHang(
}

mozilla::ipc::IPCResult ContentParent::RecvAddCertException(
const nsACString& aSerializedCert, uint32_t aFlags,
const nsACString& aHostName, int32_t aPort,
const OriginAttributes& aOriginAttributes, bool aIsTemporary,
const nsACString& aSerializedCert, const nsACString& aHostName,
int32_t aPort, const OriginAttributes& aOriginAttributes, bool aIsTemporary,
AddCertExceptionResolver&& aResolver) {
nsCOMPtr<nsISupports> certObj;
nsresult rv = NS_DeserializeObject(aSerializedCert, getter_AddRefs(certObj));
Expand All @@ -6564,7 +6563,7 @@ mozilla::ipc::IPCResult ContentParent::RecvAddCertException(
rv = NS_ERROR_FAILURE;
} else {
rv = overrideService->RememberValidityOverride(
aHostName, aPort, aOriginAttributes, cert, aFlags, aIsTemporary);
aHostName, aPort, aOriginAttributes, cert, aIsTemporary);
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions dom/ipc/ContentParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -1236,10 +1236,9 @@ class ContentParent final : public PContentParent,
mozilla::ipc::IPCResult RecvBHRThreadHang(const HangDetails& aHangDetails);

mozilla::ipc::IPCResult RecvAddCertException(
const nsACString& aSerializedCert, uint32_t aFlags,
const nsACString& aHostName, int32_t aPort,
const OriginAttributes& aOriginAttributes, bool aIsTemporary,
AddCertExceptionResolver&& aResolver);
const nsACString& aSerializedCert, const nsACString& aHostName,
int32_t aPort, const OriginAttributes& aOriginAttributes,
bool aIsTemporary, AddCertExceptionResolver&& aResolver);

mozilla::ipc::IPCResult RecvAutomaticStorageAccessPermissionCanBeGranted(
nsIPrincipal* aPrincipal,
Expand Down
4 changes: 2 additions & 2 deletions dom/ipc/PContent.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,8 @@ parent:
/*
* Adds a certificate exception for the given hostname and port.
*/
async AddCertException(nsCString aSerializedCert, uint32_t aFlags,
nsCString aHostName, int32_t aPort, OriginAttributes aOriginAttributes,
async AddCertException(nsCString aSerializedCert, nsCString aHostName,
int32_t aPort, OriginAttributes aOriginAttributes,
bool aIsTemporary)
returns (nsresult success);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ addMessageListener("add-turns-certs", certs => {
port,
{},
cert,
Ci.nsICertOverrideService.ERROR_UNTRUSTED,
false
);
});
Expand Down
1 change: 0 additions & 1 deletion mobile/android/modules/geckoview/GeckoViewProgress.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ var IdentityHandler = {
uri.port,
{},
cert,
{},
{}
);

Expand Down
13 changes: 1 addition & 12 deletions netwerk/test/unit/test_be_conservative.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,7 @@ function storeCertOverride(port, cert) {
let certOverrideService = Cc[
"@mozilla.org/security/certoverride;1"
].getService(Ci.nsICertOverrideService);
let overrideBits =
Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_TIME |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(
hostname,
port,
{},
cert,
overrideBits,
true
);
certOverrideService.rememberValidityOverride(hostname, port, {}, cert, true);
}

function startClient(port, beConservative, expectSuccess) {
Expand Down
13 changes: 1 addition & 12 deletions netwerk/test/unit/test_be_conservative_error_handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,7 @@ function storeCertOverride(port, cert) {
let certOverrideService = Cc[
"@mozilla.org/security/certoverride;1"
].getService(Ci.nsICertOverrideService);
let overrideBits =
Ci.nsICertOverrideService.ERROR_UNTRUSTED |
Ci.nsICertOverrideService.ERROR_TIME |
Ci.nsICertOverrideService.ERROR_MISMATCH;
certOverrideService.rememberValidityOverride(
hostname,
port,
{},
cert,
overrideBits,
true
);
certOverrideService.rememberValidityOverride(hostname, port, {}, cert, true);
}

function startClient(port, beConservative, expectSuccess) {
Expand Down
Loading

0 comments on commit b4c45d4

Please sign in to comment.