Changeset 741

Show
Ignore:
Timestamp:
07/11/06 13:17:15
Author:
douglm
Message:

Enable ssl connections from httpclient. Currently accepts any certificate.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/bldfiles/buildwar.xml

    r723 r741  
    301301    <copy todir="${app.dest.lib}" file="${commons-collections.jar}"/> 
    302302    <copy todir="${app.dest.lib}" file="${commons-httclient.jar}"/> 
     303    <copy todir="${app.dest.lib}" file="${commons-ssl.jar}"/> 
    303304 
    304305    <!-- add the jdbcdriver if defined --> 
  • trunk/calendar3/bldfiles/defjars.properties

    r724 r741  
    8585commons-logging.jar=${commons.dir}/commons-logging.jar 
    8686 
     87#      commons-ssl.jar    Used by httpclient for https 
     88commons-ssl.jar=${commons.dir}/commons-ssl.jar 
     89 
    8790#      commons-validator.jar    Used for struts. 
    8891commons-validator.jar=${commons.dir}/commons-validator-1.3.0.jar 
  • trunk/calendar3/caldavClientApi/build.xml

    r415 r741  
    4040 
    4141    <path id="compile.classpath"> 
     42      <pathelement location="${commons-ssl.jar}"/> 
    4243      <pathelement location="${httpclient.jar}"/> 
    4344      <pathelement location="${ical4j.jar}"/> 
  • trunk/calendar3/caldavClientApi/src/org/bedework/caldav/client/api/CaldavClientIo.java

    r736 r741  
    6565import org.apache.commons.httpclient.HostConfiguration; 
    6666import org.apache.commons.httpclient.HttpMethod; 
     67import org.apache.commons.httpclient.contrib.ssl.BaseProtocolSocketFactory; 
    6768import org.apache.commons.httpclient.protocol.Protocol; 
    68 import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; 
    69 import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory; 
     69//import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; 
     70//import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory; 
     71import org.apache.commons.ssl.TrustMaterial; 
    7072import org.apache.log4j.Logger; 
    7173 
     
    116118 
    117119    if (secure) { 
     120      /* 
    118121      ProtocolSocketFactory pfact = new SSLProtocolSocketFactory(); 
    119122      Protocol pr = new Protocol("https", pfact, port); 
    120123      Protocol.registerProtocol( "https", pr); 
    121  
    122       config.setHost(host, port, pr); 
     124      */ 
     125      BaseProtocolSocketFactory f = new BaseProtocolSocketFactory(); 
     126 
     127      warn("Trusting all certificates"); 
     128      // might as well trust the usual suspects: 
     129      //f.addTrustMaterial(TrustMaterial.CACERTS); 
     130      f.addTrustMaterial(TrustMaterial.TRUST_ALL); 
     131 
     132      // here's where we start trusting usertrust.com's CA: 
     133      //f.addTrustMaterial(new TrustMaterial(pemCert)); 
     134 
     135      Protocol trustHttps = new Protocol("https", f, 443); 
     136      Protocol.registerProtocol("https", trustHttps); 
     137 
     138 
     139      config.setHost(host, port, trustHttps); 
    123140    } else { 
    124141      config.setHost(host, port); 
     
    131148    } 
    132149    */ 
     150    if (debug) { 
     151      debugMsg("uri set to " + config.getHostURL()); 
     152    } 
    133153 
    134154    httpManager.getParams().setConnectionTimeout(timeOut); 
     
    296316  } 
    297317 
     318  protected void warn(String msg) { 
     319    getLogger().warn(msg); 
     320  } 
     321 
    298322  protected void logIt(String msg) { 
    299323    getLogger().info(msg);