-
Notifications
You must be signed in to change notification settings - Fork 170
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
OpenSSL 3 FIPS mode - creating encrypted RSA key pair fails with PEM_write_bio_PrivateKey_traditional: initialization error (OpenSSL::PKey::PKeyError) #643
Comments
I was reproduce this issue on the current master branch < 97fb410> with OpenSSL 3.0.9 FIPS built from the source. The reproducing steps: Install the OpenSSL seeing the Documents - How to debug Ruby OpenSSL binding. Check the enabled FIPS and fips and base providers by this testing program.
Compile
Check the compiled Ruby binding is linked to the OpenSSL 3.0.9, and FIPS is enabled.
Here is your script.
Your reproducing script fails on FIPS as reported.
Your script succeeds as reported.
|
I think this might be unfixable. OpenSSL's traditional PEM encryption format uses MD5 to derive encryption keys from the password, but MD5 is prohibited under the FIPS mode, hence it fails. We should document this. There is also room for improvement in the exception message. Running the code with
|
@rhenium Thanks for the info. In that case, I think we can improve the logic to print the error message to tell users the reason with a better error message, and I think that can be a solution to close this issue ticket. As a note OpenSSL 3.0 FIPS supports FIPS 140-2, and OpenSSL 3.1 FIPS supports FIPS 140-3. I learned it recently. :)
Those are nice tips. For another improvement, perhaps, we might be able to create an issue template for this repository, adding the info as a reporting way. |
I plan to list up all the supported encryptions in Ruby OpenSSL binding, then to compare the specification with OpenSSL 3.0 FIPS (FIPS 140-2) and OpenSSL 3.1 FIPS (FIPS 140-3) manually to decide how to implement. |
#645 updates the RDoc for exporting PKeys. |
yes, thanks for your support, the output of those two commands is not exactly identical, but it should do the trick:
|
I'm trying to execute the first example from docs: https://docs.ruby-lang.org/en/master/OpenSSL.html#module-OpenSSL-label-Examples
And I'm not able to execute the following code:
The error I'm getting is:
The same code works fine without the FIPS mode.
I'm using Ubuntu 22.04LTS with the following versions:
The text was updated successfully, but these errors were encountered: