summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-06 17:08:21 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-06 17:08:21 +0000
commit3eedf9156cf01751423a99ef2939ec81964155d2 (patch)
tree9cc29f6a4e68821dcdaa57058bf44871bcd4fd8c /ext
parentdd53813e38e2839b08cc540df6296c392dbf3c25 (diff)
* lib/net/http.rb: spin off https code again.
* lib/net/https.rb: new file. * ext/openssl/lib/net/https.rb: removed. moved to net/https with modifications. * ext/openssl/lib/net/protocol.rb: removed. merged with net/http. * lib/net/protocol.rb: new class BufferedIO. * lib/net/protocol.rb: InternetMessageIO < BufferedIO. * lib/net/protocol.rb: BufferedIO.new takes an IO. * lib/net/smtp.rb: follow InternetMessageIO's change. * lib/net/pop.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/openssl/lib/net/https.rb102
-rw-r--r--ext/openssl/lib/net/protocols.rb56
2 files changed, 0 insertions, 158 deletions
diff --git a/ext/openssl/lib/net/https.rb b/ext/openssl/lib/net/https.rb
deleted file mode 100644
index 772a504e74..0000000000
--- a/ext/openssl/lib/net/https.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-=begin
-= $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU Yuuzou <gotoyuzo@notwork.org>
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Requirements
- This program requires Net 1.2.0 or higher version.
- You can get it from RAA or Ruby's CVS repository.
-
-= Version
- $Id$
-
- 2001/11/06: Contiributed to Ruby/OpenSSL project.
-
-== class Net::HTTP
-
-== Example
-
-Simple HTTP client is here:
-
- require 'net/http'
- host, port, path = "localhost", 80, "/"
- if %r!http://(.*?)(?::(\d+))?(/.*)! =~ ARGV[0]
- host = $1
- port = $2.to_i if $2
- path = $3
- end
- h = Net::HTTP.new(host, port)
- h.request_get(path) {|res| print res.body }
-
-It can be replaced by follow one:
-
- require 'net/https'
- host, port, path = "localhost", 80, "/"
- if %r!(https?)://(.*?)(?::(\d+))?(/.*)! =~ ARGV[0]
- scheme = $1
- host = $2
- port = $3 ? $3.to_i : ((scheme == "http") ? 80 : 443)
- path = $4
- end
- h = Net::HTTP.new(host, port)
- h.use_ssl = true if scheme == "https" # enable SSL/TLS
- h.request_get(path) {|res| print res.body }
-
-=== Instance Methods
-
-: use_ssl
- returns ture if use SSL/TLS with HTTP.
-
-: use_ssl=((|true_or_false|))
- sets use_ssl.
-
-: peer_cert
- return the X.509 certificates the server presented.
-
-: key=((|key|))
- Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
- (This method is appeared in Michal Rokos's OpenSSL extention.)
-
-: key_file=((|path|))
- Sets a private key file to use in PEM format.
-
-: cert=((|cert|))
- Sets an OpenSSL::X509::Certificate object as client certificate.
- (This method is appeared in Michal Rokos's OpenSSL extention.)
-
-: cert_file=((|path|))
- Sets pathname of a X.509 certification file in PEM format.
-
-: ca_file=((|path|))
- Sets path of a CA certification file in PEM format.
- The file can contrain several CA certificats.
-
-: ca_path=((|path|))
- Sets path of a CA certification directory containing certifications
- in PEM format.
-
-: verify_mode=((|mode|))
- Sets the flags for server the certification verification at
- begining of SSL/TLS session.
- OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER is acceptable.
-
-: verify_callback=((|proc|))
- Sets the verify callback for the server certification verification.
-
-: verify_depth=((|num|))
- Sets the maximum depth for the certificate chain verification.
-
-: cert_store=((|store|))
- Sets the X509::Store to verify peer certificate.
-
-=end
-
-# HTTPS implementation is merged in to net/http.
-require 'net/http'
diff --git a/ext/openssl/lib/net/protocols.rb b/ext/openssl/lib/net/protocols.rb
deleted file mode 100644
index 073d4f3027..0000000000
--- a/ext/openssl/lib/net/protocols.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-=begin
-= $RCSfile$ -- SSL/TLS enhancement for Net.
-
-= Info
- 'OpenSSL for Ruby 2' project
- Copyright (C) 2001 GOTOU YUUZOU <gotoyuzo@notwork.org>
- All rights reserved.
-
-= Licence
- This program is licenced under the same licence as Ruby.
- (See the file 'LICENCE'.)
-
-= Requirements
- This program requires Net 1.2.0 or higher version.
- You can get it from RAA or Ruby's CVS repository.
-
-= Version
- $Id$
-
- 2001/11/06: Contiributed to Ruby/OpenSSL project.
-=end
-
-require 'net/protocol'
-require 'forwardable'
-require 'openssl'
-
-module Net
- class SSLIO < InternetMessageIO
- extend Forwardable
-
- def_delegators(:@ssl_context,
- :key=, :cert=, :key_file=, :cert_file=,
- :ca_file=, :ca_path=,
- :verify_mode=, :verify_callback=, :verify_depth=,
- :timeout=, :cert_store=)
-
- def initialize(addr, port, otime = nil, rtime = nil, dout = nil)
- super
- @ssl_context = OpenSSL::SSL::SSLContext.new()
- end
-
- def ssl_connect()
- unless @ssl_context.verify_mode
- warn "warning: peer certificate won't be verified in this SSL session."
- @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
- end
- @socket = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)
- @socket.sync_close = true
- @socket.connect
- end
-
- def peer_cert
- @socket.peer_cert
- end
- end
-end