[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-dev] SSL over spdy with Jetty 9
|
Hi Thomas,
Just to clarify things further, I have attached two sets of example test client and test server.
1) TestClientOld.java and TestServerOld.java
I am using jetty 7 along with npn-boot jar npn 7.6.2.v20120308 as vmargs. The client is able to receive SSL encrypted information from the server.
2) TestClient.java and TestServer.java
I am using jetty 9.0.0.M5 and npn-boot-1.1.1.v20121030.jar (in vmargs). Though I am able to send unencrypted information from the server to client, I get a time out exception when I use SSL.
The two sets of server and client codes are very much similar except for a few minor changes to suit the new jetty 9 apis. maybe I am missing something really simple but sespite spending an entire day I am still not able to figure where I am going wrong.
Thanking for your time and assistance,
Abhinav
On Tue, Feb 12, 2013 at 6:03 PM, Abhinav Rajan
<abhinav.rajan0@xxxxxxxxx> wrote:
Hi Thomas,
Please find below the test client code. I'm just printing the data sent by the server.
Thank you so much for looking into this.
--Abhinav
import java.io.File;
import java.net.InetSocketAddress;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.npn.NextProtoNego;
import org.eclipse.jetty.spdy.api.DataInfo;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.api.Session;
import org.eclipse.jetty.spdy.api.Stream;
import org.eclipse.jetty.spdy.api.StreamFrameListener;
import org.eclipse.jetty.spdy.api.StringDataInfo;
import org.eclipse.jetty.spdy.api.SynInfo;
import org.eclipse.jetty.spdy.client.SPDYClient;
import org.eclipse.jetty.util.Fields;
/**
* Put <code>-Xbootclasspath/p:lib/spdy/npn-boot-1.1.1.v20121030.jar</code> as
* vmarg.
*/
public class TestClient {
/**
* Main method.
* @param args
* @throws Exception
*/
private static final String keystoreFile = "/Users/abhinavsunderrajan/Documents/workspace/PlatformCore/src/test/resources/certificates/dev-test-client/dev-test-client.jks";
private static final File keystorePasswordFile = new File(
"/Users/abhinavsunderrajan/Documents/workspace/PlatformCore/src/test/resources/certificates/dev-test-client/store-password");
private static final String serverCertificateFile = "/Users/abhinavsunderrajan/Documents/workspace/PlatformCore/src/test/resources/certificates/dev-test-platform/dev-test-platform.cer";
private static final String caCertificateFile = "/Users/abhinavsunderrajan/Documents/workspace/PlatformCore/src/test/resources/certificates/platformCA/cacert.pem";
public static void main(final String[] args) throws Exception {
try {
// create client
NextProtoNego.debug = true;
SPDYClient.Factory clientFactory = new SPDYClient.Factory(
SecurityHelper.getSSLContextFactory(keystoreFile,
keystorePasswordFile, serverCertificateFile,
caCertificateFile));
clientFactory.start();
SPDYClient client = clientFactory.newSPDYClient(SPDY.V3);
System.out.println("Trying to get a session with the server....");
// create a session to the server running on localhost port 8181
Session session = client.connect(
new InetSocketAddress("localhost", 8181), null).get(10,
TimeUnit.SECONDS);
// this listener receives data from the server and prints it
StreamFrameListener streamListener = new StreamFrameListener.Adapter() {
public void onData(final Stream stream, final DataInfo dataInfo) {
// Data received from server
String content = dataInfo.asString("UTF-8", true);
System.out.println("SPDY content: " + content);
}
};
// Start a new session, and configure the stream listener
final Stream stream = session.syn(new SynInfo(new Fields(), false),
streamListener).getAssociatedStream();
stream.data(new StringDataInfo("hello platform", false));
} catch (Exception e) {
e.printStackTrace(); }
}
}
On Tue, Feb 12, 2013 at 4:41 PM, Thomas Becker
<tbecker@xxxxxxxxxxx> wrote:
Hi Abhinav,
this should be straight forward. Could you please paste your whole TestClient code? Does it work with a browser as client?
Cheers,
Thomas
Am 2/8/13 5:09 AM, schrieb Abhinav Rajan:
Hello,
I recently upgraded to Jetty 9. I am trying to send data to a SPDY
client over SSL and I am getting a time out exception. Please find the
details of the exception below. I have set NextProtoNego.debug to true.
I am using npn-boot-1.1.1.v20121030.jar.
VMargs:
-Xbootclasspath/p://Users/abhinav/Desktop/npn-boot-1.1.1.v20121030.jar
I have tried it it out with 8.12 and 7.62 versions of the npn boot jar.
Kindly note that I was able to send data over SSL when we used Jetty 7
along with the npn 7.6.2.v20120308 version. Also the code works fine
without SSL.
************ SPDY Exception ************
[C] NPN supported for ac42091[SSLEngine[hostname=127.0.0.1 port=53182]
SSL_NULL_WITH_NULL_NULL]
[C] NPN protocols not sent by server for
ac42091[SSLEngine[hostname=127.0.0.1 port=53182] SSL_NULL_WITH_NULL_NULL]
java.util.concurrent.TimeoutException
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:130)
at TestClient.main(TestClient.java:52)
************ SPDY Client ************
NextProtoNego.debug = true;
SPDYClient.Factory clientFactory = new SPDYClient.Factory(
SecurityHelper.getSSLContextFactory(keystoreFile,
keystorePasswordFile, serverCertificateFile,
caCertificateFile));
clientFactory.start();
SPDYClient client = clientFactory.newSPDYClient(SPDY.V3);
************ SPDY Server ************
// Wire up and start the connector
Server server = new Server();
SPDYServerConnector connector = new SPDYServerConnector(server,
SecurityHelper.getSSLContextFactory(keystoreFile,
keystorePasswordFile, serverCertificateFile,
caCertificateFile), frameListener);
connector.setHost("localhost");
connector.setPort(53182);
server.addConnector(connector);
server.start();
server.join();
Thanks,
Abhinav
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev
Attachment:
TestClient.java
Description: Binary data
Attachment:
TestServer.java
Description: Binary data
Attachment:
TestClientOld.java
Description: Binary data
Attachment:
TestServerOld.java
Description: Binary data