File tree Expand file tree Collapse file tree 3 files changed +34
-46
lines changed
Expand file tree Collapse file tree 3 files changed +34
-46
lines changed Original file line number Diff line number Diff line change 1+ Fri Jan 8 21:15:21 2010 NARUSE, Yui <
[email protected] >
2+
3+ * lib/net/http, lib/net/https: move content from net/https to
4+ net/http. [ruby-dev:39986]
5+
16Fri Jan 8 14:06:01 2010 NAKAMURA Usaku <
[email protected] >
27
38 * io.c (rb_io_s_read): close the IO if an exception is raised on
Original file line number Diff line number Diff line change 2626#++
2727
2828require 'net/protocol'
29+ autoload :OpenSSL , 'openssl'
2930require 'uri'
3031
3132module Net #:nodoc:
@@ -544,7 +545,33 @@ def started?
544545
545546 # returns true if use SSL/TLS with HTTP.
546547 def use_ssl?
547- false # redefined in net/https
548+ @use_ssl
549+ end
550+
551+ # Turn on/off SSL.
552+ # This flag must be set before starting session.
553+ # If you change use_ssl value after session started,
554+ # a Net::HTTP object raises IOError.
555+ def use_ssl = ( flag )
556+ flag = ( flag ? true : false )
557+ if started? and @use_ssl != flag
558+ raise IOError , "use_ssl value changed, but session already started"
559+ end
560+ @use_ssl = flag
561+ end
562+
563+ SSL_ATTRIBUTES = %w(
564+ ssl_version key cert ca_file ca_path cert_store ciphers
565+ verify_mode verify_callback verify_depth ssl_timeout
566+ )
567+ attr_accessor ( *SSL_ATTRIBUTES )
568+
569+ # return the X.509 certificates the server presented.
570+ def peer_cert
571+ if not use_ssl? or not @socket
572+ return nil
573+ end
574+ @socket . io . peer_cert
548575 end
549576
550577 # Opens TCP connection and HTTP session.
Original file line number Diff line number Diff line change 11=begin
22
3- = $RCSfile$ -- SSL/TLS enhancement for Net::HTTP.
3+ = net/https -- SSL/TLS enhancement for Net::HTTP.
44
55== Info
66 'OpenSSL for Ruby 2' project
1111 This program is licenced under the same licence as Ruby.
1212 (See the file 'LICENCE'.)
1313
14- == Requirements
15- This program requires Net 1.2.0 or higher version.
16- You can get it from RAA or Ruby's CVS repository.
17-
18- == Version
19- $Id$
20-
21- 2001-11-06: Contiributed to Ruby/OpenSSL project.
22- 2004-03-06: Some code is merged in to net/http.
23-
2414== Example
2515
2616Here is a simple HTTP client:
10090
10191require 'net/http'
10292require 'openssl'
103-
104- module Net
105- class HTTP
106- remove_method :use_ssl?
107- def use_ssl?
108- @use_ssl
109- end
110-
111- # Turn on/off SSL.
112- # This flag must be set before starting session.
113- # If you change use_ssl value after session started,
114- # a Net::HTTP object raises IOError.
115- def use_ssl = ( flag )
116- flag = ( flag ? true : false )
117- if started? and @use_ssl != flag
118- raise IOError , "use_ssl value changed, but session already started"
119- end
120- @use_ssl = flag
121- end
122-
123- SSL_ATTRIBUTES = %w(
124- ssl_version key cert ca_file ca_path cert_store ciphers
125- verify_mode verify_callback verify_depth ssl_timeout
126- )
127- attr_accessor ( *SSL_ATTRIBUTES )
128-
129- def peer_cert
130- if not use_ssl? or not @socket
131- return nil
132- end
133- @socket . io . peer_cert
134- end
135- end
136- end
You can’t perform that action at this time.
0 commit comments