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

Review OpenSSL::X509::Store #392

Merged
merged 7 commits into from Aug 21, 2020
Merged

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Aug 12, 2020

Update docs, tests, and improve error handling.


x509store: update rdoc for X509::Store and X509::StoreContext

Add more details about each method, and add reference to OpenSSL man
pages.


x509store: let X509::Store#add_file raise TypeError if nil is given

Undo special treatment of nil and simply pass the value to
StringValueCStr().

nil was never a valid argument for the method; OpenSSL::X509::StoreError
with an unhelpful error message "system lib" was raised in that case.


x509store: emit warning if arguments are given to X509::Store.new

Anything passed to OpenSSL::X509::Store.new was always ignored. Let's
emit an explicit warning to not confuse users.


x509store: refactor X509::StoreContext#chain

Use ossl_x509_sk2ary() to create an array of OpenSSL::X509::Certificate
from STACK_OF(X509).


x509store: avoid ossl_raise() calls with NULL message

Use the OpenSSL function name that caused the error to generate a better
error message.


test/openssl/test_x509store: break up test_verify

The test case is huge and too complex. Break it up into separate test
cases for better documentation.


test/openssl/test_x509store: tidy up tests for X509::Store#add_cert

Rename the test case to test_add_cert_duplicate to clarify what it is
actually testing.

Undo special treatment of nil and simply pass the value to
StringValueCStr().

nil was never a valid argument for the method; OpenSSL::X509::StoreError
with an unhelpful error message "system lib" was raised in that case.
Anything passed to OpenSSL::X509::Store.new was always ignored. Let's
emit an explicit warning to not confuse users.
Use ossl_x509_sk2ary() to create an array of OpenSSL::X509::Certificate
from STACK_OF(X509).
Use the OpenSSL function name that caused the error to generate a better
error message.
Add more details about each method, and add reference to OpenSSL man
pages.
The test case is huge and too complex. Break it up into separate test
cases for better documentation.
Rename the test case to test_add_cert_duplicate to clarify what it is
actually testing.
XrXr referenced this pull request in ruby/ruby Aug 19, 2020
`OpenSSL::TestX509Store#test_verify` has been failing intermittently on
CI about once a day:
  - http://ci.rvm.jp/results/trunk-random2@phosphorus-docker/3121244
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3117661
  - http://ci.rvm.jp/results/trunk-random1@phosphorus-docker/3111684

According to the test:
 > OpenSSL uses time(2) while Time.now uses clock_gettime(CLOCK_REALTIME),
 > and there may be difference.

This difference is could be the cause for the flaky failures. Let's see
if giving the certificate more room solves the problem.

In any case, I will revert this in a week. I think changes to these
should go to https://github.com/ruby/openssl/?
@ko1
Copy link
Contributor

ko1 commented Aug 19, 2020

@rhenium rhenium merged commit d756d64 into ruby:master Aug 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants