How to set up SSL on an embedded Jetty?

 ̄綄美尐妖づ 提交于 2019-12-03 08:45:26

A response from the Jetty Users Email Group:

David,

You need to create an instance of SslContextFactory and configure it with your keystore parameters. After that you'll need to pass that instance to the SslSelectChannelConnector's constructor. Recently modified configuration file jetty-ssl.xml shows how it is done in XmlConfiguration, and could be easily translated into code. This will be documented in Jetty Wiki as soon as we get a chance.

-Michael

I've been using this and it works just fine for me thus far:

    //Set up SSL keystore
    SslContextFactory sslContextFactory = new SslContextFactory("/etc/mykeystore");
    sslContextFactory.setKeyStorePassword("yourpassword");
    SslSelectChannelConnector selectChannelConnector = new SslSelectChannelConnector(sslContextFactory);
    selectChannelConnector.setPort(4567); //your port
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!