Skip to content

Commit

Permalink
Check bool environment variables are "1" or "true"
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalexling committed Dec 26, 2020
1 parent 8931ba8 commit 7a7cb78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/util/util.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ class String
self.chars.all? { |c| c.alphanumeric? || c == '_' }
end
end

def env_is_true?(key : String) : Bool
val = ENV[key.upcase]? || ENV[key.downcase]?
return false unless val
val.downcase.in? "1", "true"
end
4 changes: 1 addition & 3 deletions src/util/web.cr
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ module HTTP
class Client
private def self.exec(uri : URI, tls : TLSContext = nil)
previous_def uri, tls do |client, path|
disable_ssl_verification = ENV["DISABLE_SSL_VERIFICATION"]? ||
ENV["disable_ssl_verification"]?
if disable_ssl_verification && client.tls?
if client.tls? && env_is_true? "DISABLE_SSL_VERIFICATION"
Logger.debug "Disabling SSL verification"
client.tls.verify_mode = OpenSSL::SSL::VerifyMode::NONE
end
Expand Down

0 comments on commit 7a7cb78

Please sign in to comment.