Skip to content
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

Added SSL verify to options #124

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/mqtt/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class Client
# Last ping response time
attr_reader :last_ping_response

# SSL Verify Mode
attr_reader :ssl_verify

# Timeout between select polls (in seconds)
SELECT_TIMEOUT = 0.5

Expand All @@ -75,7 +78,8 @@ class Client
:will_payload => nil,
:will_qos => 0,
:will_retain => false,
:ssl => false
:ssl => false,
:ssl_verify => OpenSSL::SSL::VERIFY_PEER
}

# Create and connect a new MQTT Client
Expand Down Expand Up @@ -205,7 +209,11 @@ def key=(*args)
# Set a path to a file containing a PEM-format CA certificate and enable peer verification
def ca_file=(path)
ssl_context.ca_file = path
ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER unless path.nil?
end

# Set the SSL verify mode
def ssl_verify=(mode)
ssl_context.verify_mode = mode unless mode.nil?
end

# Set the Will for the client
Expand Down