[#7978] Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...>

This patch adds support for getting the uid and gid of the peer

27 messages 2006/06/09
[#8004] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/16

In article <200606091528.30171.jfh@cise.ufl.edu>,

[#8005] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/06/16

On Friday 16 June 2006 11:51, Tanaka Akira wrote:

[#8010] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...17n.org> 2006/06/17

In article <200606161327.35948.jfh@cise.ufl.edu>,

[#8191] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/10

On Saturday 17 June 2006 06:27, Tanaka Akira wrote:

[#8193] Re: Patch for Unix socket peer credentials — Tanaka Akira <akr@...> 2006/07/11

In article <200607101352.16804.jfh@cise.ufl.edu>,

[#8212] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/13

On Tuesday 11 July 2006 00:10, Tanaka Akira wrote:

[#8217] Re: Patch for Unix socket peer credentials — nobu@... 2006/07/14

Hi,

[#8257] Re: Patch for Unix socket peer credentials — "James F. Hranicky" <jfh@...> 2006/07/18

On Thursday 13 July 2006 22:48, nobu@ruby-lang.org wrote:

[#8258] Re: Patch for Unix socket peer credentials — Eric Hodel <drbrain@...7.net> 2006/07/18

On Jul 18, 2006, at 12:27 PM, James F. Hranicky wrote:

[#8073] 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...>

Solaris 10

23 messages 2006/06/27
[#8074] Re: 1.8.5p1 build failure on Solaris 10 — Yukihiro Matsumoto <matz@...> 2006/06/28

Hi,

[#8078] Re: 1.8.5p1 build failure on Solaris 10 — "Daniel Berger" <Daniel.Berger@...> 2006/06/28

Yukihiro Matsumoto wrote:

[#8079] Re: 1.8.5p1 build failure on Solaris 10 — ts <decoux@...> 2006/06/28

>>>>> "D" == Daniel Berger <Daniel.Berger@qwest.com> writes:

[#8096] Re: 1.8.5p1 build failure on Solaris 10 — ville.mattila@... 2006/06/29

ts <decoux@moulon.inra.fr> wrote on 28.06.2006 17:37:00:

Re: [PATCH] SSL client certificate support for OpenURI

From: "Marshall T. Vandegrift" <mvandegrift@...>
Date: 2006-06-16 19:59:24 UTC
List: ruby-core #8006

Tanaka Akira <akr@m17n.org> writes:

> In article <7zfyi7wy13.fsf@epictetus.iss.local>,
>   "Marshall T. Vandegrift" <mvandegrift@iss.net> writes:
>
>> The attached patch modifies 'open-uri.rb' to allow users to specify
>> SSL client certificates and keys for HTTPS sessions.
>
> 1. Why :ssl_cert and :ssl_key are separated?

Well, the cheeky answer is because they're separate. :-)

I think that it's most common to load these items from separate files,
and even if not, the way the OpenSSL library and Ruby bindings are
written, it's easier to pull the X.509 certificate and private key out
of a PKCS#12 structure than cram them into one.

Convention-wise, OpenSSL, the Ruby OpenSSL bindings, 'net/https', and
other SSL-using library modules all expect the certificate and key to
be separate.  OpenSSL doesn't really provide a convenient data
structure to bundle them together.

> 2. I think the option name(s) should contain a word "client".

My reasoning behind the names was keeping clear the mapping to
'net/https' -- just as :ssl_verify_mode maps to Net::HTTP#verify_mode,
:ssl_cert maps to HTTP#cert and :ssl_key maps to HTTP#key.

If you think that it's more clear to use :ssl_client_key and
:ssl_client_cert, I've attached to this message a patch which uses
those names instead.

Thank you!

-- 
Marshall T. Vandegrift <mvandegrift@iss.net>
ISS.Researcher | 404.236.3986w 518.859.4559m

Attachments (1)

open-uri-ssl_cert-patch-2.diff (2.05 KB, text/x-patch)
--- ruby-trunk/lib/open-uri.rb	2006-06-13 13:46:48.000000000 -0400
+++ ruby-modified/lib/open-uri.rb	2006-06-16 14:18:15.000000000 -0400
@@ -101,6 +101,8 @@
     :read_timeout => true,
     :ssl_ca_cert => nil,
     :ssl_verify_mode => nil,
+    :ssl_client_cert => nil,
+    :ssl_client_key => nil
   }
 
   def OpenURI.check_options(options) # :nodoc:
@@ -282,6 +284,24 @@
       else
         store.set_default_paths
       end
+      if options[:ssl_client_cert]
+        if options[:ssl_client_cert].is_a? OpenSSL::X509::Certificate
+          http.cert = options[:ssl_client_cert]
+        else
+          http.cert = OpenSSL::X509::Certificate.new(File.read(options[:ssl_client_cert]))
+        end
+      end
+      if options[:ssl_client_key]
+        if options[:ssl_client_key].is_a? OpenSSL::PKey::PKey
+          http.key = options[:ssl_client_key]
+        else
+          begin
+            http.key = OpenSSL::PKey::DSA.new(File.read(options[:ssl_client_key]))
+          rescue OpenSSL::PKey::DSAError
+            http.key = OpenSSL::PKey::RSA.new(File.read(options[:ssl_client_key]))
+          end
+        end
+      end
       store.set_default_paths
       http.cert_store = store
     end
@@ -607,6 +627,24 @@
     #
     #  :ssl_verify_mode is used to specify openssl verify mode.
     #
+    # [:ssl_client_cert]
+    #  Synopsis:
+    #    :ssl_client_cert=>filename
+    #    :ssl_client_cert=>x509cert
+    #
+    #  :ssl_client_cert is used to specify a client certificate for
+    #  SSL.  It may be either a filename or an
+    #  OpenSSL::X509::Certificate object.
+    #
+    # [:ssl_client_key]
+    #  Synopsis:
+    #    :ssl_client_key=>filename
+    #    :ssl_client_key=>pkey
+    #
+    #  :ssl_client_key is used to specify a detached client private
+    #  key for SSL.  It may be either a filename or an
+    #  OpenSSL::PKey::PKey object.
+    #
     # OpenURI::OpenRead#open returns an IO like object if block is not given.
     # Otherwise it yields the IO object and return the value of the block.
     # The IO object is extended with OpenURI::Meta.

In This Thread

Prev Next