Jetty SslConnector的弃用方法

时间:2011-03-07 14:07:09

标签: java ssl jetty deprecated

SslConnector.java界面已在最新的Jetty 7.3.1.v20110307 中更改。

几乎所有方法都被标记为已弃用,但未提及替换接口或方法。

我已经检查了jetty-usersjetty-dev邮件列表,但没有运气。

是否有人知道将来如何更改代码?

提前致谢!

2 个答案:

答案 0 :(得分:6)

好的,从subversion changelog中挖掘出相应的提交(疯狂),结果是应该使用SslContextFactory

示例:

final SslContextFactory sslContextFactory = new SslContextFactory(sKeyStore);
sslContextFactory.setKeyStorePassword(sPassword);

final SslSocketConnector conn = new SslSocketConnector(sslContextFactory);
conn.setReuseAddress(true);
// ...

答案 1 :(得分:1)

以你自己的答案为基础:

Server server = new Server();

// Encrypt the connection using a valid certificate/keystore
SslContextFactory sslContextFactory = new SslContextFactory("path/keystore.jks");
sslContextFactory.setKeyStorePassword("password");

// Create a new SocketConnector at port 443, which is the default port for
// HTTPS web pages (no port number needs to be specified in the browser).
SslSocketConnector sslConnector = new SslSocketConnector(sslContextFactory);
sslConnector.setPort(443);

// Add the SocketConnector to the server
server.setConnectors(new Connector[] {sslConnector});