diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-11 14:26:27 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-11 14:26:27 +0000 |
commit | 82a17ed0b361b027acd2afe9ee0ea6424d194ad1 (patch) | |
tree | a844b5ce254a530d009df2a140db21a5f75adbb8 /lib/net | |
parent | b24465ba536f30550afff0e80cf23182b6b28d51 (diff) | |
download | ruby-82a17ed0b361b027acd2afe9ee0ea6424d194ad1.tar.gz ruby-82a17ed0b361b027acd2afe9ee0ea6424d194ad1.tar.xz ruby-82a17ed0b361b027acd2afe9ee0ea6424d194ad1.zip |
* lib/net/imap.rb (starttls): supported the STARTTLS command.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/imap.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 82d5b2973..a5c143371 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -322,6 +322,24 @@ module Net send_command("LOGOUT") end + # Sends a STARTTLS command to start TLS session. + def starttls(ctx = nil) + if @sock.kind_of?(OpenSSL::SSL::SSLSocket) + raise RuntimeError, "already using SSL" + end + send_command("STARTTLS") do |resp| + if resp.kind_of?(TaggedResponse) && resp.name == "OK" + if ctx + @sock = OpenSSL::SSL::SSLSocket.new(@sock, ctx) + else + @sock = OpenSSL::SSL::SSLSocket.new(@sock) + end + @sock.sync_close = true + @sock.connect + end + end + end + # Sends an AUTHENTICATE command to authenticate the client. # The +auth_type+ parameter is a string that represents # the authentication mechanism to be used. Currently Net::IMAP |