-
Notifications
You must be signed in to change notification settings - Fork 168
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
Fix OpenSSL::PKey.read that cannot parse PKey in the FIPS mode. #615
Conversation
Rebased on the latest master branch. |
Tomorrow I manually will check if the new compiler warnings are printed or not on each case in the CI. |
… mode. This commit is a workaround to avoid the error below that the `OpenSSL::PKey.read` fails with the OpenSSL 3.0 FIPS mode. ``` $ openssl genrsa -out key.pem 4096 $ ruby -e "require 'openssl'; OpenSSL::PKey.read(File.read('key.pem'))" -e:1:in `read': Could not parse PKey (OpenSSL::PKey::PKeyError) from -e:1:in `<main>' ``` The root cause is on the OpenSSL side. The `OSSL_DECODER_CTX_set_selection` doesn't apply the selection value properly if there are multiple providers, and a provider (e.g. "base" provider) handles the decoder implementation, and another provider (e.g. "fips" provider) handles the keys. The workaround is to create `OSSL_DECODER_CTX` variable each time without using the `OSSL_DECODER_CTX_set_selection`.
We want to run the unit tests in the FIPS mode too.
It's to test the `OpenSSL::PKey.read` in the `test/openssl/test_pkey.rb`. I added the pending status to the following tests failing on the FIPS mode case in the `test/openssl/test_pkey.rb`. * `test_ed25519` * `test_x25519` * `test_compare?`
Manually checking the compiler warnings on the CI is very hard. First, I identified what CI cases I need to check on this PR's CI. To find the cases, I executed this PR and master branch's CIs with one commit #631 to check the compiler warnings.
The CI result for this PR + a commit of checking the compiler warnings The CI result for the master branch (
Then I will be checking if there are the compiler warnings in the cases in this PR's CI. |
I checked it manually. And I confirmed there are no new compiler warnings by this PR.
|
This PR is to fix the following issue that is managed as one of the issues at #603 on the FIPS mode. This PR is based on the PR #608. So, please consider reviewing and merging the #608 first. Then I can rebase this PR on the latest master branch.
There are some commits on this PR. The first 3 commits are basically from the PR #603. Then the 4th commit is the main commit to fix this issue. The patch is the same with what I mentioned at #603 (comment). The 4th and 5th commits are to run the unit test
test/openssl/test_pkey.rb
.https://github.com/junaruga/openssl/actions/runs/4681990779/jobs/8295272065#step:11:732
Before the main 4rd commit, the
test_generic_oid_inspect
andtest_to_text
was failing in thetest/openssl/test_pkey.rb
. So, runningtest/openssl/test_pkey.rb
can test that this issue was fixed.Note that the 3 tests
test_ed25519
,test_x25519
andtest_compare?
in thetest/openssl/test_pkey.rb
are still failing due to other issues. And I am working on it at the #603 (comment).I confirmed that CI passed on my forked repository.
https://github.com/junaruga/openssl/actions/runs/4724029713/jobs/8380737782#step:12:64