Changeset 2388 in subversion


Ignore:
Timestamp:
Apr 14, 2009 3:35:12 AM (4 years ago)
Author:
alec
Message:
  • Support STARTTLS in IMAP connection (#1485284)
Location:
trunk/roundcubemail
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r2385 r2388  
    22=========================== 
    33 
     4- Support STARTTLS in IMAP connection (#1485284) 
    45- Fix DEL key problem in search boxes (#1485528) 
    56- Support several e-mail addresses per user from virtuser_file (#1485678) 
  • trunk/roundcubemail/config/main.inc.php.dist

    r2338 r2388  
    5252// leave blank to show a textbox at login, give a list of hosts 
    5353// to display a pulldown menu or set one host as string. 
    54 // To use SSL connection, enter ssl://hostname:993 
     54// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls:// 
    5555$rcmail_config['default_host'] = ''; 
    5656 
  • trunk/roundcubemail/program/include/rcmail.php

    r2384 r2388  
    437437      $host = $a_host['host']; 
    438438      $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; 
    439       $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $config['default_port']); 
    440     } 
    441     else 
    442       $imap_port = $config['default_port']; 
    443  
     439      if(!empty($a_host['port'])) 
     440        $imap_port = $a_host['port']; 
     441      else if ($imap_ssl && $imap_ssl != 'tls') 
     442        $imap_port = 993; 
     443    } 
     444     
     445    $imap_port = $imap_port ? $imap_port : $config['default_port']; 
    444446 
    445447    /* Modify username with domain if required   
  • trunk/roundcubemail/program/lib/imap.inc

    r2378 r2388  
    336336        if ($bye && strncmp($string, '* BYE ', 6) == 0) { 
    337337                return true; 
     338 
    338339        } 
    339340        return false; 
     
    382383 
    383384        return false; 
     385} 
     386 
     387function iil_C_ClearCapability(&$conn) 
     388{ 
     389        $conn->capability = array(); 
     390        $conn->capability_readed = false; 
    384391} 
    385392 
     
    565572        $result = false; 
    566573         
    567         //initialize connection 
     574        // initialize connection 
    568575        $conn              = new iilConnection; 
    569576        $conn->error       = ''; 
     
    599606                return false; 
    600607        } 
     608 
    601609        if (!$ICL_PORT) { 
    602610                $ICL_PORT = 143; 
    603611        } 
    604      
    605612        //check for SSL 
    606         if ($ICL_SSL) { 
     613        if ($ICL_SSL && $ICL_SSL != 'tls') { 
    607614                $host = $ICL_SSL . '://' . $host; 
    608615        } 
    609          
    610         //open socket connection 
     616 
    611617        $conn->fp = fsockopen($host, $ICL_PORT, $errno, $errstr, 10); 
    612618        if (!$conn->fp) { 
     
    625631 
    626632        $conn->message .= $line; 
     633 
     634        // TLS connection 
     635        if ($ICL_SSL == 'tls' && iil_C_GetCapability($conn, 'STARTTLS')) { 
     636                if (version_compare(PHP_VERSION, '5.1.0', '>=')) { 
     637                        iil_PutLine($conn->fp, 'stls000 STARTTLS'); 
     638 
     639                        $line = iil_ReadLine($conn->fp, 4096); 
     640                        if (!iil_StartsWith($line, 'stls000 OK')) { 
     641                                $iil_error = "Server responded to STARTTLS with: $line"; 
     642                                $iil_errornum = -2; 
     643                                return false; 
     644                        } 
     645 
     646                        if (!stream_socket_enable_crypto($conn->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { 
     647                                $iil_error = "Unable to negotiate TLS"; 
     648                                $iil_errornum = -2; 
     649                                return false; 
     650                        } 
     651                         
     652                        // Now we're authenticated, capabilities need to be reread 
     653                        iil_C_ClearCapability($conn); 
     654                } 
     655        } 
    627656 
    628657        if (strcasecmp($auth_method, "check") == 0) { 
Note: See TracChangeset for help on using the changeset viewer.