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

add missing verification parameter flags #5643

Merged
merged 1 commit into from
Dec 13, 2020
Merged

add missing verification parameter flags #5643

merged 1 commit into from
Dec 13, 2020

Conversation

ediskandarov
Copy link

Adding 2 missing verification parameter flags:

  • X509_V_FLAG_NO_ALT_CHAINS If the initial chain is not trusted, do not attempt to build an alternative chain.
  • X509_V_FLAG_NO_CHECK_TIME Do not check certificate/CRL validity against current time

Corresponding OpenSSL code:
/~https://github.com/openssl/openssl/blob/OpenSSL_1_1_0-stable/include/openssl/x509_vfy.h#L227-L234

@alex
Copy link
Member

alex commented Dec 13, 2020

Can you share what your use case for these is? We generally add things only as required, not merely for completeness.

@ediskandarov
Copy link
Author

ediskandarov commented Dec 13, 2020

I want to incorporate efforts from pyca/pyopenssl#948 into a tool for certificate checking.

For my special needs, I only want to test a certificate against the trust chain and ignore expiration checks.

What I have to do now is this:

from OpenSSL import crypto

store = crypto.X509Store()

# Do not check certificate/CRL validity against current time
# /~https://github.com/openssl/openssl/blob/OpenSSL_1_1_1-stable/include/openssl/x509_vfy.h#L241-L242
X509_V_FLAG_NO_CHECK_TIME = 0x200000

store.load_locations(cafile=CA_FILE)
store.set_flags(X509_V_FLAG_NO_CHECK_TIME)

store_ctx = crypto.X509StoreContext(
    store,
    certificate,
    chain=chain,
)

store_ctx.verify_certificate()

I'm aware contribution to pyOpenSSL is discouraged, so I try my luck here.

@ediskandarov
Copy link
Author

@alex , I've updated my post several times.

Please let me know if the final version makes sense for you.

@alex
Copy link
Member

alex commented Dec 13, 2020

That's hlepful, thanks.

@alex alex merged commit 9b4a19e into pyca:master Dec 13, 2020
@ediskandarov ediskandarov deleted the update-verification-flags branch December 13, 2020 16:44
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants