Class: ApartmentAcmeClient::Verifier
- Inherits:
-
Object
- Object
- ApartmentAcmeClient::Verifier
- Defined in:
- app/models/apartment_acme_client/verifier.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ Verifier
constructor
A new instance of Verifier.
-
#properly_configured? ⇒ Boolean
Determine whether this alias is properly configured Causes makes a request to a remote server (which should be THIS server) and determines whether the request was properly received.
Constructor Details
#initialize(url) ⇒ Verifier
Returns a new instance of Verifier.
7 8 9 10 |
# File 'app/models/apartment_acme_client/verifier.rb', line 7 def initialize(url) @url = url @verify_over_https = ApartmentAcmeClient.verify_over_https ? true : false end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'app/models/apartment_acme_client/verifier.rb', line 5 def url @url end |
Instance Method Details
#properly_configured? ⇒ Boolean
Determine whether this alias is properly configured Causes makes a request to a remote server (which should be THIS server) and determines whether the request was properly received
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/apartment_acme_client/verifier.rb', line 15 def properly_configured? = { open_timeout: 5, use_ssl: @verify_over_https, verify_mode: OpenSSL::SSL::VERIFY_NONE # because we might not have a valid cert yet } Net::HTTP.start(url, ) do |http| # Because the engine could be mounted anywhere, we need to get the target # path from the Engine Routes verify_path = ApartmentAcmeClient::Engine.routes.url_helpers.verify_path response = http.get(verify_path) return false unless response.is_a?(Net::HTTPSuccess) response.body == "TRUE" end rescue SocketError, Net::OpenTimeout, Errno::ECONNREFUSED # SocketError if the server name doesn't exist in DNS # OpenTimeout if no server responds # ECONNREFUSED if the server responds with "No" false end |