I'm trying to setup a minimal HTTP over SPDY server with Jetty, for testing purposes. I'm working on this code:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.spdy.http.HTTPSPDYServerConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
public class MySPDYHelloServer {
public static void main(String[] args) throws Exception {
Server server = new Server();
SslContextFactory sslFactory = new SslContextFactory();
sslFactory.setKeyStorePath("dummy_keystore.jks");
sslFactory.setKeyStorePassword("password");
sslFactory.setProtocol("TLSv1");
Connector connector = new HTTPSPDYServerConnector(sslFactory);
connector.setPort(8443);
server.addConnector(connector);
server.setHandler( new AbstractHandler(){
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("<h1>Hello World</h1>");
}
} );
server.start();
server.join();
}
}
I've generated the keystore with:
keytool -genkey -keystore dummy_keystore.jks
When I point Google Chrome (SPDY enabled) to https://localhost:8443
it warns me about the untrusted certificate then loads forever.
The pure SPDY client-server examples (from here) work and a simple HTTPS server work too; the issue seems related to the HTTPSPDYServerConnector class.
Here's the list of the JARs that I'm using:
jetty-all-7.6.7.v20120910.jar
npn-boot-7.6.2.v20120308.jar
servlet-api-2.5.jar
spdy-core-7.6.7.v20120910.jar
spdy-jetty-7.6.7.v20120910.jar
spdy-jetty-http-7.6.7.v20120910.jar
And for what concerns my Java environment:
$ cat /opt/jdk1.7.0_07/release
JAVA_VERSION="1.7.0"
OS_NAME="Linux"
OS_VERSION="2.6"
OS_ARCH="i586"
Solution addendum
jesse mcconnell provided the answer, anyway those who use Eclipse may find the following useful.
The JAR npn-boot-7.6.2.v20120308.jar
must (also) be placed in:
Run Configurations... -> Classpath -> Bootstrap Entries -> Add External JARs
Note that since order matters, that entry must appear before the JRE System Library
.