Use File.exist?, restoring TLS certificate verification - #177
Open
nabramovitz wants to merge 1 commit into
Open
Conversation
File.exists? is not present on current Ruby, so the three guards in
open_ssl_socket raise NoMethodError before a socket is opened.
The first of them is the only path that sets VERIFY_PEER - everything
else in open_ssl_socket runs with the ctx.verify_mode = VERIFY_NONE set
at the top - so on current Ruby, passing a trust store through
SSLParams(:ts_files) does not merely fail to verify, it raises, and the
only reachable option is an unverified TLS connection. The other two
guards affect cert_file and key_file the same way.
exist? has been the spelling since 1.9 and exists? was only ever an
alias, so this changes nothing on older Rubies.
Verified against two RabbitMQ 4.2.9 brokers, both holding certificates
from the same throwaway CA - one issued to localhost, one to
wrong.example.invalid:
before: SSLParams(ts_files: ca) -> NoMethodError, both brokers
after: SSLParams(ts_files: ca) -> connects to localhost,
refuses wrong.example.invalid
(hostname does not match)
ssl: true is unchanged - it accepts both, as documented.
Refs stompgem#176
This file contains hidden or 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
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.
Fixes #176.
File.exists?is not present on current Ruby, so the three guards inConnection#open_ssl_socketraiseNoMethodErrorbefore a socket isopened.
The first of them is the only path that sets
VERIFY_PEER— everythingelse in
open_ssl_socketruns with thectx.verify_mode = VERIFY_NONEsetat the top — so on current Ruby, passing a trust store through
SSLParams(:ts_files)does not merely fail to verify, it raises, and theonly reachable option is an unverified TLS connection. The other two guards
affect
cert_fileandkey_filethe same way.exist?has been the spelling since 1.9 andexists?was only ever analias, so this changes nothing on older Rubies.
Verified
Two RabbitMQ 4.2.9 brokers, both holding certificates from the same
throwaway CA — one issued to
localhost, one towrong.example.invalid:Ruby 3.3.11, stomp 1.4.10.