-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fail hard if SSL certs or keys are invalid #2848
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously if an invalid SSL cert or key (e.g. blank file, mismatching private and public key, etc.) were specified, Puma would quietly accept them, bind to the port, and mysteriously fail with an error only after a client initiates a connection: ``` SSL error, peer: ::1, peer cert: : #<Puma::MiniSSL::SSLError: OpenSSL error: error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher - 193> ``` We now check the OpenSSL return values and raise an exception if the cert or key cannot be loaded.
stanhu
force-pushed
the
sh-check-openssl-certs
branch
from
March 27, 2022 05:06
b881b30
to
462a2d2
Compare
MSP-Greg
changed the title
Fail hard if OpenSSL cannot load cert or key
Fail hard if SSL certs or keys are invalid
Mar 27, 2022
MSP-Greg
approved these changes
Mar 27, 2022
Does it make sense to add a test to the test suite for this? |
Maybe something like the following added to unless Puma.jruby?
def test_invalid_cert
assert_raises(Puma::MiniSSL::SSLError) do
start_server { |ctx| ctx.cert = __FILE__ }
end
end
def test_invalid_key
assert_raises(Puma::MiniSSL::SSLError) do
start_server { |ctx| ctx.key = __FILE__ }
end
end
def test_invalid_cert_pem
assert_raises(Puma::MiniSSL::SSLError) do
start_server { |ctx|
ctx.instance_variable_set(:@cert, nil)
ctx.cert_pem = 'Not a valid pem'
}
end
end
def test_invalid_key_pem
assert_raises(Puma::MiniSSL::SSLError) do
start_server { |ctx|
ctx.instance_variable_set(:@key, nil)
ctx.key_pem = 'Not a valid pem'
}
end
end
def test_invalid_ca
assert_raises(Puma::MiniSSL::SSLError) do
start_server { |ctx|
ctx.ca = __FILE__
}
end
end
end All five fail on master, pass with the PR. I can push a commit... @stanhu - thanks for the PR, input testing is always good. After your previous PR, I was thinking the same thing (raise on invalid)... |
Great idea on the test! |
MSP-Greg
added a commit
to MSP-Greg/puma
that referenced
this pull request
Apr 3, 2022
* Fail hard if OpenSSL cannot load cert or key Previously if an invalid SSL cert or key (e.g. blank file, mismatching private and public key, etc.) were specified, Puma would quietly accept them, bind to the port, and mysteriously fail with an error only after a client initiates a connection: ``` SSL error, peer: ::1, peer cert: : #<Puma::MiniSSL::SSLError: OpenSSL error: error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher - 193> ``` We now check the OpenSSL return values and raise an exception if the cert or key cannot be loaded. * Add SSL invalid tests Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
7 tasks
nateberkopec
pushed a commit
that referenced
this pull request
Aug 22, 2022
* Fail hard if OpenSSL cannot load cert or key Previously if an invalid SSL cert or key (e.g. blank file, mismatching private and public key, etc.) were specified, Puma would quietly accept them, bind to the port, and mysteriously fail with an error only after a client initiates a connection: ``` SSL error, peer: ::1, peer cert: : #<Puma::MiniSSL::SSLError: OpenSSL error: error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher - 193> ``` We now check the OpenSSL return values and raise an exception if the cert or key cannot be loaded. * Add SSL invalid tests Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
JuanitoFatas
pushed a commit
to JuanitoFatas/puma
that referenced
this pull request
Sep 9, 2022
* Fail hard if OpenSSL cannot load cert or key Previously if an invalid SSL cert or key (e.g. blank file, mismatching private and public key, etc.) were specified, Puma would quietly accept them, bind to the port, and mysteriously fail with an error only after a client initiates a connection: ``` SSL error, peer: ::1, peer cert: : #<Puma::MiniSSL::SSLError: OpenSSL error: error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher - 193> ``` We now check the OpenSSL return values and raise an exception if the cert or key cannot be loaded. * Add SSL invalid tests Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Previously if an invalid SSL cert or key (e.g. blank file, mismatching
private and public key, etc.) were specified, Puma would quietly
accept them, bind to the port, and mysteriously fail with an error
only after a client initiates a connection:
We now check the OpenSSL return values and raise an exception if the
cert or key cannot be loaded. For example:
Your checklist for this pull request
[ci skip]
to the title of the PR.#issue
" to the PR description or my commit messages.