[前][次][番号順一覧][スレッド一覧]

ruby-changes:47150

From: nobu <ko1@a...>
Date: Wed, 5 Jul 2017 15:27:49 +0900 (JST)
Subject: [ruby-changes:47150] nobu:r59265 (trunk): un.rb: support https

nobu	2017-07-05 15:27:43 +0900 (Wed, 05 Jul 2017)

  New Revision: 59265

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59265

  Log:
    un.rb: support https
    
    * lib/un.rb: add https support.  based on the patch by Flavio
      Castelli <flavio@c...> in [ruby-core:81901].
      [Feature #13714]

  Modified files:
    trunk/lib/un.rb
Index: lib/un.rb
===================================================================
--- lib/un.rb	(revision 59264)
+++ lib/un.rb	(revision 59265)
@@ -313,18 +313,29 @@ end https://github.com/ruby/ruby/blob/trunk/lib/un.rb#L313
 #   --do-not-reverse-lookup     disable reverse lookup
 #   --request-timeout=SECOND    request timeout in seconds
 #   --http-version=VERSION      HTTP version
+#   --ssl-certificate=CERT      The SSL certificate file for the server
+#   --ssl-private-key=KEY       The SSL private key file for the server certificate
 #   -v                          verbose
 #
 
 def httpd
   setup("", "BindAddress=ADDR", "Port=PORT", "MaxClients=NUM", "TempDir=DIR",
-        "DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION") do
+        "DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION",
+        "SSLCertificate=CERT", "SSLPrivateKey=KEY") do
     |argv, options|
     require 'webrick'
     opt = options[:RequestTimeout] and options[:RequestTimeout] = opt.to_i
     [:Port, :MaxClients].each do |name|
       opt = options[name] and (options[name] = Integer(opt)) rescue nil
     end
+    if cert = options[:SSLCertificate]
+      require 'webrick/https'
+      require 'openssl'
+      options[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read(cert))
+      options[:SSLEnable] = true
+      options[:SSLPrivateKey] &&= OpenSSL::PKey::RSA.new(File.read(options[:SSLPrivateKey]))
+      options[:Port] ||= 8443   # HTTPS Alternate
+    end
     options[:Port] ||= 8080     # HTTP Alternate
     options[:DocumentRoot] = argv.shift || '.'
     s = WEBrick::HTTPServer.new(options)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]