Encode hostnames to fix #1510

This commit is contained in:
Eliott Appleford 2015-05-05 23:56:08 +01:00
parent de5234818d
commit 27684e2ef3

View file

@ -117,6 +117,7 @@ module Middleman
config[:ssl_private_key] = opts[:ssl_private_key] if opts[:ssl_private_key] config[:ssl_private_key] = opts[:ssl_private_key] if opts[:ssl_private_key]
end end
@host = Socket.gethostname.tr(' ', '+')
@port = @app.config[:port] @port = @app.config[:port]
@https = @app.config[:https] @https = @app.config[:https]
@ -193,10 +194,7 @@ module Middleman
http_opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new File.read ssl_private_key http_opts[:SSLPrivateKey] = OpenSSL::PKey::RSA.new File.read ssl_private_key
else else
# use a generated self-signed cert # use a generated self-signed cert
http_opts[:SSLCertName] = [ http_opts[:SSLCertName] = [%w(CN localhost), %W(CN #{host})].uniq
%w(CN localhost),
%w(CN #{Socket.gethostname})
].uniq
end end
end end
@ -264,7 +262,7 @@ module Middleman
# Returns the URI the preview server will run on # Returns the URI the preview server will run on
# @return [URI] # @return [URI]
def uri(host = Socket.gethostname) def uri(host=@host)
scheme = https? ? 'https' : 'http' scheme = https? ? 'https' : 'http'
URI("#{scheme}://#{host}:#{@port}/") URI("#{scheme}://#{host}:#{@port}/")
end end