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?
org.eclipse.jetty.http.ssl.SslContextFactory
is deprecated in 7.6; try using
org.eclipse.jetty.util.ssl.SslContextFactory
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});