使用SSL的已弃用Embedded Jetty 7.6 [英] Deprecated Embedded Jetty 7.6 using SSL
问题描述
我正在尝试构建一个到目前为止还不错的嵌入式码头应用程序.但是,如果我尝试使用SSL,似乎所有方法都已弃用.我在此处的stackoverflow上找到了一篇帖子,海报的作者使用SslContextFactory解决了他的问题,但是如果我复制这些行,我的想法也将SslContextFactory标记为已弃用.
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?
推荐答案
我正在使用Jetty 7.6版.这是我使用的导入.
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;
下面是一些使用新的SslContextFactory的示例代码.
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});
这篇关于使用SSL的已弃用Embedded Jetty 7.6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!