我正在使用jetty 9.0.0.M4版本,并试图将其配置为接受SSL连接。 按照指示: http://www.eclipse.org/jetty/documentation/current/configuring-connectors.html以编程方式为Jetty 9嵌入式配置SSL
我已经设法写出了一些有用的东西。然而,我写的代码看起来很丑陋,不必要的复杂。 任何想法如何正确地做到这一点?
final Server server = new Server(Config.Server.PORT);
SslContextFactory contextFactory = new SslContextFactory();
contextFactory.setKeyStorePath(Config.Location.KEYSTORE_LOCATION);
contextFactory.setKeyStorePassword("******");
SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(contextFactory, org.eclipse.jetty.http.HttpVersion.HTTP_1_1.toString());
HttpConfiguration config = new HttpConfiguration();
config.setSecureScheme("https");
config.setSecurePort(Config.Server.SSL_PORT);
config.setOutputBufferSize(32786);
config.setRequestHeaderSize(8192);
config.setResponseHeaderSize(8192);
HttpConfiguration sslConfiguration = new HttpConfiguration(config);
sslConfiguration.addCustomizer(new SecureRequestCustomizer());
HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(sslConfiguration);
ServerConnector connector = new ServerConnector(server, sslConnectionFactory, httpConnectionFactory);
connector.setPort(Config.Server.SSL_PORT);
server.addConnector(connector);
server.start();
server.join();
关于这个问题的不错工作 –