开发者

Jetty SslConnector's deprecated methods

SslConnector.java interface has been changed in the newest Jetty 7.3.1.v20110307.

Almost all off the开发者_JAVA技巧 methods have been marked as deprecated without mentioning the replacement interface or methods to use.

I've checked the jetty-users and jetty-dev mailing lists for the information with no luck.

Is there anybody out there who knows how should be the code changed for the future?

Thanks in advance!


Okay, digging out from the subversion changelog for the corresponding commits (crazy) it came out that SslContextFactory should be used.

Example:

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

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


Building on your own answer:

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});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜