Configuring SSL

To configure the standalone HTTP transport to use SSL, you'll need to add an <http:destination> definition to your XML configuration file. See the Configuration guide to learn how to supply your own XML configuration file to CXF. If you are already using Spring, this can be added to your existing beans definitions. For more information about configuring TLS, see the Configuring TLS page.

Destinations in CXF are responsible for listening for server side requests.

<beans xmlns=""

  <http:destination name="{}GreeterImplPort.http-destination">    
  <httpj:engine-factory bus="cxf">
  <!-- you just need to specify the TLS Server configuration for the certain port -->
    <httpj:engine port="9003">
        <sec:keyManagers keyPassword="password">
          <sec:keyStore type="JKS" password="password" 
          <sec:keyStore type="JKS" password="password"
          <!-- these filters ensure that a ciphersuite with
               export-suitable or null encryption is used,
               but exclude anonymous Diffie-Hellman key change as
               this is vulnerable to man-in-the-middle attacks -->
        <sec:clientAuthentication want="true" required="true"/>

Add the static content pages into the jetty server

The CXF standalone http transport is based on the jetty server. The code below shows how to get the jetty server from the destination and how to add the static content path to the jetty server.

    // get the jetty server form the destination
    EndpointInfo ei = new EndpointInfo();
    Destination destination = df.getDestination(ei);
    JettyHTTPDestination jettyDestination = (JettyHTTPDestination) destination;
    ServerEngine engine = jettyDestination.getEngine();
    Handler handler = engine.getServant(new URL(serviceFactory.getAddress()));
    org.mortbay.jetty.Server server = handler.getServer(); // The Server

    // We have to create a HandlerList structure that includes both a ResourceHandler for the static
    // content as well as the ContextHandlerCollection created by CXF (which we retrieve as serverHandler). 
    Handler serverHandler = server.getHandler();
    HandlerList handlerList = new HandlerList();
    ResourceHandler resourceHandler = new ResourceHandler();

    // replace the CXF servlet connect collection with the list.
    // and tell the handler list that it is alive.

    // setup the resource handler
    File staticContentFile = new File(staticContentPath); // ordinary pathname.
    URL targetURL = new URL("file://" + staticContentFile.getCanonicalPath());
    FileResource fileResource = new FileResource(targetURL);