Deprecated Embedded Jetty 7.6 using SSL

坚强是说给别人听的谎言 提交于 2019-12-25 07:48:13

问题


I am trying to build an embedded jetty application which is fine so far. But if i try to use SSL it seems all methods are deprecated. I found a post here on stackoverflow where the poster solved his problem by using the SslContextFactory but if i copy those lines my ide marks the SslContextFactory as deprecated too.

What would be the proper way of solving this?

i had a look at the following similar questions but they don't seem to solve my problem:

  • Jetty SslConnector's deprecated methods
  • How to set up SSL on an embedded Jetty?

回答1:


org.eclipse.jetty.http.ssl.SslContextFactory

is deprecated in 7.6; try using

org.eclipse.jetty.util.ssl.SslContextFactory



回答2:


I'm using Jetty version 7.6. Here are the imports I used.

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.server.ssl.SslSocketConnector;
import org.eclipse.jetty.server.Connector;

Below is some example code using the new SslContextFactory.

Server server = new Server();

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

// Create new socket connector using the contextFactory
SslSocketConnector sslConnector = new SslSocketConnector(sslContextFactory);
sslConnector.setPort(443);

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


来源:https://stackoverflow.com/questions/8359429/deprecated-embedded-jetty-7-6-using-ssl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!