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

X509StoreContextError: unable to get local issuer certificate #109

Closed
tetsuo-cpp opened this issue Jun 3, 2022 · 5 comments · Fixed by #110
Closed

X509StoreContextError: unable to get local issuer certificate #109

tetsuo-cpp opened this issue Jun 3, 2022 · 5 comments · Fixed by #110
Assignees
Labels
bug Something isn't working component:verification Core verification functionality

Comments

@tetsuo-cpp
Copy link
Contributor

I noticed this exception raised when running verification:

Traceback (most recent call last):
  File "/Users/tetsuo/Code/sigstore-python/env/bin/sigstore", line 8, in <module>
    sys.exit(main())
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/tetsuo/Code/sigstore-python/sigstore/_cli.py", line 299, in _verify
    if verify(
  File "/Users/tetsuo/Code/sigstore-python/sigstore/_verify.py", line 128, in verify
    store_ctx.verify_certificate()
  File "/Users/tetsuo/Code/sigstore-python/env/lib/python3.9/site-packages/OpenSSL/crypto.py", line 1896, in verify_certificate
    raise self._exception_from_context()
OpenSSL.crypto.X509StoreContextError: [20, 0, 'unable to get local issuer certificate']

This is trivial to trigger for me. All I need to do is this:

$ sigstore sign test_file.txt --output-signature --output-certificate
$ sigstore verify test_file.txt --cert test_file.txt.crt --signature test_file.txt.sig

From looking around, the error seems to indicate that we might need to pass the entire certificate chain into verification.

@tetsuo-cpp tetsuo-cpp added bug Something isn't working component:verification Core verification functionality labels Jun 3, 2022
@tetsuo-cpp tetsuo-cpp self-assigned this Jun 3, 2022
@tetsuo-cpp
Copy link
Contributor Author

Weird... I tried with an older certificate I had lying around and I didn't have this problem. So it's something specific to the ones being returned from Fulcio now. I wonder what has changed.

@tetsuo-cpp
Copy link
Contributor Author

tetsuo-cpp commented Jun 3, 2022

Still unsure about this. The Fulcio signing key doesn't appear to have changed. When I write the chain certificates to the disk, I still have the same problem when I use the openssl tool directly.

I'm doing:

$ openssl verify -CAfile sigstore/_store/fulcio.crt.pem -untrusted chain0.crt -untrusted chain1.crt test_file.txt.crt
test_file.txt.crt:
error 20 at 0 depth lookup:unable to get local issuer certificate

@di
Copy link
Member

di commented Jun 3, 2022

I believe Fulcio did introduce an intermediate certificate, see sigstore/cosign#1774

@tetsuo-cpp
Copy link
Contributor Author

tetsuo-cpp commented Jun 3, 2022

I believe Fulcio did introduce an intermediate certificate, see sigstore/cosign#1774

Thanks! That looks promising. I'll take a look.

@tetsuo-cpp
Copy link
Contributor Author

@di Yep, that was the issue. Thanks for that. I'll make a PR now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component:verification Core verification functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants