2012-04-11 93 views
1

我目前正在升级我们的码头版本从7.1.6到7.6.2。我注意到我们目前使用的很多SslSocketConnector方法自从我们的旧版本以来已被弃用。什么是jetty http客户端中的SslSocketConnector setPort()的替代品?

从我在其他一些SO问题中看到的,我设法使用SslContextFactory代替大多数方法。

但是,我似乎无法找到任何等效的SslSocketConnectorsetPort(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"); 

回答

2

管理使用来解决这个问题我已经存在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); 
+1

我用Jetty 7.4和' setKeyStorePath'被命名为'setKeyStore'并且它必须被设置。与其SslSocketConnector表亲不同,它不会默认用户的主目录。 – FabienB 2012-10-25 21:28:56

+0

良好的投入,欢呼声。 :) – 2012-10-26 08:54:06