Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible bug in in _has_root_cert #52

Open
dpc opened this issue May 19, 2022 · 1 comment
Open

Possible bug in in _has_root_cert #52

dpc opened this issue May 19, 2022 · 1 comment

Comments

@dpc
Copy link

dpc commented May 19, 2022

I added some debug prints:

    def _has_root_cert(self):
        if sys.platform == "darwin":
            name = self.ca_cert_file_path
        else:
            name = "{server} Root CA".format(server=self.server)
        print("Vaild cert? ")
        print(self.check_valid_cert(name, usage="CT,T,T", is_root=True))
        if self.check_valid_cert(name, usage="CT,T,T", is_root=True):
            print("Yes? True.")
            return True
        print("No? False.")
        return False

result:

> mtls -s some-prod certificate create
Retrieving CRL from server...
Writing CRL to /home/dpc/.config/mtls/some-prod/crl.pem
Vaild cert? 
(False, False, False)
Yes? True.
Decrypting User Key...
Generating CSR for bitgo-prod
Signing CSR for verification on server...
CSR Public key does not match previous user key

AFAICT a tuple of three False values becomes True, which is :sus:.

@nocturn9x
Copy link

That's because Python's __bool__ implementation only checks if len(x) != 0. This can be fixed if any/all are used instead, depending on the use case. In this case I think any(self.check_valid_cert(name, usage="CT,T,T", is_root=True)) would work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants