什么是jetty http客户端中的SslSocketConnector setPort()的替代品?
问题描述:
我目前正在升级我们的码头版本从7.1.6到7.6.2。我注意到我们目前使用的很多SslSocketConnector方法自从我们的旧版本以来已被弃用。什么是jetty http客户端中的SslSocketConnector setPort()的替代品?
从我在其他一些SO问题中看到的,我设法使用SslContextFactory
代替大多数方法。
但是,我似乎无法找到任何等效的SslSocketConnector
的setPort(int)
方法。关于SslContextFactory
的相应方法是什么意见?
升级码头版本之前的代码:
theSSLConnector.setPort(theHTTPSPort);
theSSLConnector.setKeystore("key");
theSSLConnector.setPassword("OBF:password");
theSSLConnector.setKeyPassword("OBF:password");
theSSLConnector.setTruststore("trust");
theSSLConnector.setTrustPassword("OBF:password");
而经过:
SslContextFactory theSSLFactory = new SslContextFactory();
// Port goes here?
theSSLFactory.setKeyStorePath("key");
theSSLFactory.setKeyManagerPassword("OBF:password");
theSSLFactory.setKeyStorePassword("OBF:password");
theSSLFactory.setTrustStore("trust");
theSSLFactory.setTrustStorePassword("OBF:password");
答
管理使用来解决这个问题我已经存在SslContextFactory
作为输入参数到SslSocketConnector
构造:
SslContextFactory theSSLFactory = new SslContextFactory();
theSSLFactory.setKeyStorePath("key");
theSSLFactory.setKeyManagerPassword("OBF:password");
theSSLFactory.setKeyStorePassword("OBF:password");
theSSLFactory.setTrustStore("trust");
theSSLFactory.setTrustStorePassword("OBF:password");
SslSocketConnector theSSLConnector = new SslSocketConnector(theSSLFactory);
theSSLConnector.setPort(theHTTPSPort);
我用Jetty 7.4和' setKeyStorePath'被命名为'setKeyStore'并且它必须被设置。与其SslSocketConnector表亲不同,它不会默认用户的主目录。 – FabienB 2012-10-25 21:28:56
良好的投入,欢呼声。 :) – 2012-10-26 08:54:06