Skip to content

Commit

Permalink
Do not remove client certificate, even when TLS is disabled
Browse files Browse the repository at this point in the history
It does not really make sense to remove it, as it can lock someone out of
their account, just by temporarily disabling TLS.
  • Loading branch information
progval committed Mar 5, 2022
1 parent 53b4d00 commit ae7020f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ Network.prototype.validate = function (client) {
this.rejectUnauthorized = true;
}

if (!this.tls) {
ClientCertificate.remove(this.uuid);
}

return true;
};

Expand Down
8 changes: 4 additions & 4 deletions test/models/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ describe("Network", function () {
STSPolicies.update("irc.example.com", 7000, 0); // Cleanup
});

it("should remove client certs if TLS is disabled", function () {
it("should not remove client certs if TLS is disabled", function () {
Helper.config.public = false;

const client = {idMsg: 1, emit() {}, messageStorage: []};
Expand All @@ -216,15 +216,15 @@ describe("Network", function () {
expect(client_cert).to.not.be.null;
expect(ClientCertificate.get(network.uuid)).to.deep.equal(client_cert);

expect(network.validate(client)).to.be.true; // Deletes the cert
expect(network.validate(client)).to.be.true;

expect(ClientCertificate.get(network.uuid)).to.not.deep.equal(client_cert); // Because ClientCertificate.get regenerates it
expect(ClientCertificate.get(network.uuid)).to.deep.equal(client_cert); // Should be unchanged

ClientCertificate.remove(network.uuid);
Helper.config.public = true;
});

it("should remove client certs if there is a STS policy", function () {
it("should not remove client certs if there is a STS policy", function () {
Helper.config.public = false;

const client = {idMsg: 1, emit() {}, messageStorage: []};
Expand Down

0 comments on commit ae7020f

Please sign in to comment.