Skip to content

Commit

Permalink
Fix missing SSL hostname validation [MiM Vuln]
Browse files Browse the repository at this point in the history
  • Loading branch information
alromh87 committed Sep 13, 2020
1 parent f926bad commit 8eac124
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/em-imap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require 'em-imap/deferrable_ssl'
require 'em-imap/connection'

require 'em-imap/ssl_verifier'
require 'em-imap/authenticators'
require 'em-imap/client'
$:.shift
Expand Down
7 changes: 6 additions & 1 deletion lib/em-imap/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ module Connection
# connection could not be established, or the
# first response was BYE.
#

attr_accessor :host

def self.connect(host, port, ssl=false)
@host = host
EventMachine.connect(host, port, self).tap do |conn|
conn.start_tls if ssl
conn.start_tls(:verify_peer => true) if ssl
conn.host = @host
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/em-imap/deferrable_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module DeferrableSSL
# finished
#
# TODO: expose certificates so they can be verified.
def start_tls
def start_tls(verify_peer)
unless @ssl_deferrable
@ssl_deferrable = DG::blank
bothback{ @ssl_deferrable.fail }
Expand Down

0 comments on commit 8eac124

Please # to comment.