316382: support a more strict SSL option with certificates
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2799 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
93c9c181a0
commit
b34dbd246f
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<bundle-symbolic-name>${project.groupId}.client</bundle-symbolic-name>
|
<bundle-symbolic-name>${project.groupId}.client</bundle-symbolic-name>
|
||||||
<jetty.test.keystore>1.1</jetty.test.keystore>
|
<jetty.test.keystore>1.2-SNAPSHOT</jetty.test.keystore>
|
||||||
<jetty.test.keystore.loc>target/test-policy</jetty.test.keystore.loc>
|
<jetty.test.keystore.loc>target/test-policy</jetty.test.keystore.loc>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -673,61 +673,61 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTrustStoreLocation()
|
public String getTrustStoreLocation()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststore();
|
return _sslContextFactory.getTrustStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustStoreLocation(String trustStoreLocation)
|
public void setTrustStoreLocation(String trustStoreLocation)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststore(trustStoreLocation);
|
_sslContextFactory.setTrustStore(trustStoreLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public InputStream getTrustStoreInputStream()
|
public InputStream getTrustStoreInputStream()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststoreInputStream();
|
return _sslContextFactory.getTrustStoreInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustStoreInputStream(InputStream trustStoreInputStream)
|
public void setTrustStoreInputStream(InputStream trustStoreInputStream)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststoreInputStream(trustStoreInputStream);
|
_sslContextFactory.setTrustStoreInputStream(trustStoreInputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeyStoreLocation()
|
public String getKeyStoreLocation()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystore();
|
return _sslContextFactory.getKeyStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeyStoreLocation(String keyStoreLocation)
|
public void setKeyStoreLocation(String keyStoreLocation)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystore(keyStoreLocation);
|
_sslContextFactory.setKeyStore(keyStoreLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public InputStream getKeyStoreInputStream()
|
public InputStream getKeyStoreInputStream()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystoreInputStream();
|
return _sslContextFactory.getKeyStoreInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeyStoreInputStream(InputStream keyStoreInputStream)
|
public void setKeyStoreInputStream(InputStream keyStoreInputStream)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystoreInputStream(keyStoreInputStream);
|
_sslContextFactory.setKeyStoreInputStream(keyStoreInputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeyStorePassword(String keyStorePassword)
|
public void setKeyStorePassword(String keyStorePassword)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystorePassword(keyStorePassword);
|
_sslContextFactory.setKeyStorePassword(keyStorePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -741,35 +741,35 @@ public class HttpClient extends HttpBuffers implements Attributes
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustStorePassword(String trustStorePassword)
|
public void setTrustStorePassword(String trustStorePassword)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststorePassword(trustStorePassword);
|
_sslContextFactory.setTrustStorePassword(trustStorePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeyStoreType()
|
public String getKeyStoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystoreType();
|
return _sslContextFactory.getKeyStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeyStoreType(String keyStoreType)
|
public void setKeyStoreType(String keyStoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystoreType(keyStoreType);
|
_sslContextFactory.setKeyStoreType(keyStoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTrustStoreType()
|
public String getTrustStoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststoreType();
|
return _sslContextFactory.getTrustStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustStoreType(String trustStoreType)
|
public void setTrustStoreType(String trustStoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststoreType(trustStoreType);
|
_sslContextFactory.setTrustStoreType(trustStoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.eclipse.jetty.client;
|
package org.eclipse.jetty.client;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
|
||||||
import org.eclipse.jetty.http.ssl.SslContextFactory;
|
import org.eclipse.jetty.http.ssl.SslContextFactory;
|
||||||
|
@ -18,52 +17,52 @@ public abstract class SslValidationTestBase extends SslContentExchangeTest
|
||||||
protected static Class<? extends SslConnector> __klass;
|
protected static Class<? extends SslConnector> __klass;
|
||||||
protected static int __konnector;
|
protected static int __konnector;
|
||||||
|
|
||||||
|
// certificate is valid until Jan 1, 2050
|
||||||
|
private String _keypath = MavenTestingUtils.getTargetFile("test-policy/validation/jetty-valid.keystore").getAbsolutePath();
|
||||||
|
private String _trustpath = MavenTestingUtils.getTargetFile("test-policy/validation/jetty-trust.keystore").getAbsolutePath();
|
||||||
|
private String _crlpath = MavenTestingUtils.getTargetFile("test-policy/validation/crlfile.pem").getAbsolutePath();
|
||||||
|
private String _password = "OBF:1wnl1sw01ta01z0f1tae1svy1wml";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureServer(Server server)
|
protected void configureServer(Server server)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
setProtocol("https");
|
setProtocol("https");
|
||||||
|
|
||||||
// certificate is valid until Jan 1, 2050
|
|
||||||
String keypath = MavenTestingUtils.getTargetFile("test-policy/validation/jetty-valid.keystore").getAbsolutePath();
|
|
||||||
String trustpath = new File(System.getProperty("java.home"),"./lib/security/cacerts").getAbsolutePath();
|
|
||||||
String crlpath = MavenTestingUtils.getTargetFile("test-policy/validation/crlfile.pem").getAbsolutePath();
|
|
||||||
|
|
||||||
SslContextFactory srvFactory = new SslContextFactory();
|
SslContextFactory srvFactory = new SslContextFactory();
|
||||||
srvFactory.setValidateCerts(true);
|
srvFactory.setValidateCerts(true);
|
||||||
srvFactory.setKeystore(keypath);
|
srvFactory.setKeyStore(_keypath);
|
||||||
srvFactory.setKeystorePassword("webtide");
|
srvFactory.setKeyStorePassword(_password);
|
||||||
srvFactory.setKeyManagerPassword("webtide");
|
srvFactory.setKeyManagerPassword(_password);
|
||||||
srvFactory.setTruststore(trustpath);
|
srvFactory.setTrustStore(_trustpath);
|
||||||
srvFactory.setTruststorePassword("changeit");
|
srvFactory.setTrustStorePassword(_password);
|
||||||
srvFactory.setCrlPath(crlpath);
|
srvFactory.setCrlPath(_crlpath);
|
||||||
|
|
||||||
Constructor<? extends SslConnector> constructor = __klass.getConstructor(SslContextFactory.class);
|
Constructor<? extends SslConnector> constructor = __klass.getConstructor(SslContextFactory.class);
|
||||||
SslConnector connector = constructor.newInstance(srvFactory);
|
SslConnector connector = constructor.newInstance(srvFactory);
|
||||||
connector.setMaxIdleTime(5000);
|
connector.setMaxIdleTime(5000);
|
||||||
server.addConnector(connector);
|
server.addConnector(connector);
|
||||||
|
|
||||||
Handler handler = new TestHandler(getBasePath());
|
Handler handler = new TestHandler(getBasePath());
|
||||||
|
|
||||||
ServletContextHandler root = new ServletContextHandler();
|
ServletContextHandler root = new ServletContextHandler();
|
||||||
root.setContextPath("/");
|
root.setContextPath("/");
|
||||||
root.setResourceBase(getBasePath());
|
root.setResourceBase(getBasePath());
|
||||||
ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
|
ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
|
||||||
servletHolder.setInitParameter( "gzip", "true" );
|
servletHolder.setInitParameter( "gzip", "true" );
|
||||||
root.addServlet( servletHolder, "/*" );
|
root.addServlet( servletHolder, "/*" );
|
||||||
|
|
||||||
HandlerCollection handlers = new HandlerCollection();
|
HandlerCollection handlers = new HandlerCollection();
|
||||||
handlers.setHandlers(new Handler[]{handler, root});
|
handlers.setHandlers(new Handler[]{handler, root});
|
||||||
server.setHandler( handlers );
|
server.setHandler( handlers );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureClient(HttpClient client)
|
protected void configureClient(HttpClient client)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
String trustpath = new File(System.getProperty("java.home"),"./lib/security/cacerts").getAbsolutePath();
|
client.setTrustStoreLocation(_trustpath);
|
||||||
client.setTrustStoreLocation(trustpath);
|
client.setTrustStorePassword(_password);
|
||||||
client.setTrustStorePassword("changeit");
|
|
||||||
client.setConnectorType(__konnector);
|
client.setConnectorType(__konnector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,25 +86,25 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
private Set<String> _includeCipherSuites = null;
|
private Set<String> _includeCipherSuites = null;
|
||||||
|
|
||||||
/** Keystore path. */
|
/** Keystore path. */
|
||||||
private String _keystorePath;
|
private String _keyStorePath;
|
||||||
/** Keystore provider name */
|
/** Keystore provider name */
|
||||||
private String _keystoreProvider;
|
private String _keyStoreProvider;
|
||||||
/** Keystore type */
|
/** Keystore type */
|
||||||
private String _keystoreType = "JKS";
|
private String _keyStoreType = "JKS";
|
||||||
/** Keystore input stream */
|
/** Keystore input stream */
|
||||||
private InputStream _keystoreInputStream;
|
private InputStream _keyStoreInputStream;
|
||||||
|
|
||||||
/** SSL certificate alias */
|
/** SSL certificate alias */
|
||||||
private String _certAlias;
|
private String _certAlias;
|
||||||
|
|
||||||
/** Truststore path */
|
/** Truststore path */
|
||||||
private String _truststorePath;
|
private String _trustStorePath;
|
||||||
/** Truststore provider name */
|
/** Truststore provider name */
|
||||||
private String _truststoreProvider;
|
private String _trustStoreProvider;
|
||||||
/** Truststore type */
|
/** Truststore type */
|
||||||
private String _truststoreType = "JKS";
|
private String _trustStoreType = "JKS";
|
||||||
/** Truststore input stream */
|
/** Truststore input stream */
|
||||||
private InputStream _truststoreInputStream;
|
private InputStream _trustStoreInputStream;
|
||||||
|
|
||||||
/** Set to true if client certificate authentication is required */
|
/** Set to true if client certificate authentication is required */
|
||||||
private boolean _needClientAuth = false;
|
private boolean _needClientAuth = false;
|
||||||
|
@ -116,11 +116,11 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
private boolean _allowRenegotiate = false;
|
private boolean _allowRenegotiate = false;
|
||||||
|
|
||||||
/** Keystore password */
|
/** Keystore password */
|
||||||
private transient Password _keystorePassword;
|
private transient Password _keyStorePassword;
|
||||||
/** Key manager password */
|
/** Key manager password */
|
||||||
private transient Password _keymanagerPassword;
|
private transient Password _keymanagerPassword;
|
||||||
/** Truststore password */
|
/** Truststore password */
|
||||||
private transient Password _truststorePassword;
|
private transient Password _trustStorePassword;
|
||||||
|
|
||||||
/** SSL provider name */
|
/** SSL provider name */
|
||||||
private String _sslProvider;
|
private String _sslProvider;
|
||||||
|
@ -158,7 +158,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
*/
|
*/
|
||||||
public SslContextFactory(String keystorePath)
|
public SslContextFactory(String keystorePath)
|
||||||
{
|
{
|
||||||
_keystorePath = keystorePath;
|
_keyStorePath = keystorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -169,8 +169,8 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
@Override
|
@Override
|
||||||
protected void doStart() throws Exception
|
protected void doStart() throws Exception
|
||||||
{
|
{
|
||||||
if (_keystoreInputStream == null && _keystorePath == null &&
|
if (_keyStoreInputStream == null && _keyStorePath == null &&
|
||||||
_truststoreInputStream == null && _truststorePath == null )
|
_trustStoreInputStream == null && _trustStorePath == null )
|
||||||
{
|
{
|
||||||
// Create a trust manager that does not validate certificate chains
|
// Create a trust manager that does not validate certificate chains
|
||||||
TrustManager trustAllCerts = new X509TrustManager()
|
TrustManager trustAllCerts = new X509TrustManager()
|
||||||
|
@ -248,9 +248,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
/**
|
/**
|
||||||
* @return The file or URL of the SSL Key store.
|
* @return The file or URL of the SSL Key store.
|
||||||
*/
|
*/
|
||||||
public String getKeystore()
|
public String getKeyStore()
|
||||||
{
|
{
|
||||||
return _keystorePath;
|
return _keyStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -258,20 +258,20 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param keystore
|
* @param keystore
|
||||||
* The file or URL of the SSL Key store.
|
* The file or URL of the SSL Key store.
|
||||||
*/
|
*/
|
||||||
public void setKeystore(String keystore)
|
public void setKeyStore(String keystore)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_keystorePath = keystore;
|
_keyStorePath = keystore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return The provider of the key store
|
* @return The provider of the key store
|
||||||
*/
|
*/
|
||||||
public String getKeystoreProvider()
|
public String getKeyStoreProvider()
|
||||||
{
|
{
|
||||||
return _keystoreProvider;
|
return _keyStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -279,20 +279,20 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param keystoreProvider
|
* @param keystoreProvider
|
||||||
* The provider of the key store
|
* The provider of the key store
|
||||||
*/
|
*/
|
||||||
public void setKeystoreProvider(String keystoreProvider)
|
public void setKeyStoreProvider(String keystoreProvider)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_keystoreProvider = keystoreProvider;
|
_keyStoreProvider = keystoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return The type of the key store (default "JKS")
|
* @return The type of the key store (default "JKS")
|
||||||
*/
|
*/
|
||||||
public String getKeystoreType()
|
public String getKeyStoreType()
|
||||||
{
|
{
|
||||||
return (_keystoreType);
|
return (_keyStoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -300,33 +300,33 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param keystoreType
|
* @param keystoreType
|
||||||
* The type of the key store (default "JKS")
|
* The type of the key store (default "JKS")
|
||||||
*/
|
*/
|
||||||
public void setKeystoreType(String keystoreType)
|
public void setKeyStoreType(String keystoreType)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_keystoreType = keystoreType;
|
_keyStoreType = keystoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Get the _keystoreInputStream.
|
/** Get the _keyStoreInputStream.
|
||||||
* @return the _keystoreInputStream
|
* @return the _keyStoreInputStream
|
||||||
*/
|
*/
|
||||||
public InputStream getKeystoreInputStream()
|
public InputStream getKeyStoreInputStream()
|
||||||
{
|
{
|
||||||
checkConfig();
|
checkConfig();
|
||||||
|
|
||||||
return _keystoreInputStream;
|
return _keyStoreInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Set the _keystoreInputStream.
|
/** Set the _keyStoreInputStream.
|
||||||
* @param _keystoreInputStream the _keystoreInputStream to set
|
* @param _keyStoreInputStream the _keyStoreInputStream to set
|
||||||
*/
|
*/
|
||||||
public void setKeystoreInputStream(InputStream keystoreInputStream)
|
public void setKeyStoreInputStream(InputStream keystoreInputStream)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_keystoreInputStream = keystoreInputStream;
|
_keyStoreInputStream = keystoreInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -354,9 +354,9 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
/**
|
/**
|
||||||
* @return The file name or URL of the trust store location
|
* @return The file name or URL of the trust store location
|
||||||
*/
|
*/
|
||||||
public String getTruststore()
|
public String getTrustStore()
|
||||||
{
|
{
|
||||||
return _truststorePath;
|
return _trustStorePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -364,20 +364,20 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param truststore
|
* @param truststore
|
||||||
* The file name or URL of the trust store location
|
* The file name or URL of the trust store location
|
||||||
*/
|
*/
|
||||||
public void setTruststore(String truststore)
|
public void setTrustStore(String truststore)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_truststorePath = truststore;
|
_trustStorePath = truststore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return The provider of the trust store
|
* @return The provider of the trust store
|
||||||
*/
|
*/
|
||||||
public String getTruststoreProvider()
|
public String getTrustStoreProvider()
|
||||||
{
|
{
|
||||||
return _truststoreProvider;
|
return _trustStoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -385,20 +385,20 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param truststoreProvider
|
* @param truststoreProvider
|
||||||
* The provider of the trust store
|
* The provider of the trust store
|
||||||
*/
|
*/
|
||||||
public void setTruststoreProvider(String truststoreProvider)
|
public void setTrustStoreProvider(String truststoreProvider)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_truststoreProvider = truststoreProvider;
|
_trustStoreProvider = truststoreProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return The type of the trust store (default "JKS")
|
* @return The type of the trust store (default "JKS")
|
||||||
*/
|
*/
|
||||||
public String getTruststoreType()
|
public String getTrustStoreType()
|
||||||
{
|
{
|
||||||
return _truststoreType;
|
return _trustStoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -406,33 +406,33 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param truststoreType
|
* @param truststoreType
|
||||||
* The type of the trust store (default "JKS")
|
* The type of the trust store (default "JKS")
|
||||||
*/
|
*/
|
||||||
public void setTruststoreType(String truststoreType)
|
public void setTrustStoreType(String truststoreType)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_truststoreType = truststoreType;
|
_trustStoreType = truststoreType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Get the _truststoreInputStream.
|
/** Get the _trustStoreInputStream.
|
||||||
* @return the _truststoreInputStream
|
* @return the _trustStoreInputStream
|
||||||
*/
|
*/
|
||||||
public InputStream getTruststoreInputStream()
|
public InputStream getTrustStoreInputStream()
|
||||||
{
|
{
|
||||||
checkConfig();
|
checkConfig();
|
||||||
|
|
||||||
return _truststoreInputStream;
|
return _trustStoreInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Set the _truststoreInputStream.
|
/** Set the _trustStoreInputStream.
|
||||||
* @param _truststoreInputStream the _truststoreInputStream to set
|
* @param _trustStoreInputStream the _trustStoreInputStream to set
|
||||||
*/
|
*/
|
||||||
public void setTruststoreInputStream(InputStream truststoreInputStream)
|
public void setTrustStoreInputStream(InputStream truststoreInputStream)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_truststoreInputStream = truststoreInputStream;
|
_trustStoreInputStream = truststoreInputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -532,11 +532,11 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param password
|
* @param password
|
||||||
* The password for the key store
|
* The password for the key store
|
||||||
*/
|
*/
|
||||||
public void setKeystorePassword(String password)
|
public void setKeyStorePassword(String password)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_keystorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
_keyStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -556,11 +556,11 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
* @param password
|
* @param password
|
||||||
* The password for the trust store
|
* The password for the trust store
|
||||||
*/
|
*/
|
||||||
public void setTruststorePassword(String password)
|
public void setTrustStorePassword(String password)
|
||||||
{
|
{
|
||||||
checkStarted();
|
checkStarted();
|
||||||
|
|
||||||
_truststorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
_trustStorePassword = Password.getPassword(PASSWORD_PROPERTY,password,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -751,10 +751,10 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
// parameters are set up correctly
|
// parameters are set up correctly
|
||||||
checkConfig();
|
checkConfig();
|
||||||
|
|
||||||
KeyStore keyStore = getKeyStore(_keystoreInputStream, _keystorePath, _keystoreType,
|
KeyStore keyStore = getKeyStore(_keyStoreInputStream, _keyStorePath, _keyStoreType,
|
||||||
_keystoreProvider, _keystorePassword==null? null: _keystorePassword.toString());
|
_keyStoreProvider, _keyStorePassword==null? null: _keyStorePassword.toString());
|
||||||
KeyStore trustStore = getKeyStore(_truststoreInputStream, _truststorePath, _truststoreType,
|
KeyStore trustStore = getKeyStore(_trustStoreInputStream, _trustStorePath, _trustStoreType,
|
||||||
_truststoreProvider, _truststorePassword==null? null: _truststorePassword.toString());
|
_trustStoreProvider, _trustStorePassword==null? null: _trustStorePassword.toString());
|
||||||
Collection<? extends CRL> crls = loadCRL(_crlPath);
|
Collection<? extends CRL> crls = loadCRL(_crlPath);
|
||||||
|
|
||||||
if (_validateCerts && keyStore != null)
|
if (_validateCerts && keyStore != null)
|
||||||
|
@ -791,7 +791,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
if (keyStore != null)
|
if (keyStore != null)
|
||||||
{
|
{
|
||||||
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(_keyManagerFactoryAlgorithm);
|
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(_keyManagerFactoryAlgorithm);
|
||||||
keyManagerFactory.init(keyStore,_keymanagerPassword == null?(_keystorePassword == null?null:_keystorePassword.toString().toCharArray()):_keymanagerPassword.toString().toCharArray());
|
keyManagerFactory.init(keyStore,_keymanagerPassword == null?(_keyStorePassword == null?null:_keyStorePassword.toString().toCharArray()):_keymanagerPassword.toString().toCharArray());
|
||||||
managers = keyManagerFactory.getKeyManagers();
|
managers = keyManagerFactory.getKeyManagers();
|
||||||
|
|
||||||
if (_certAlias != null)
|
if (_certAlias != null)
|
||||||
|
@ -927,7 +927,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
public boolean checkConfig()
|
public boolean checkConfig()
|
||||||
{
|
{
|
||||||
boolean check = true;
|
boolean check = true;
|
||||||
if (_keystoreInputStream == null && _keystorePath == null)
|
if (_keyStoreInputStream == null && _keyStorePath == null)
|
||||||
{
|
{
|
||||||
// configuration doesn't have a valid keystore
|
// configuration doesn't have a valid keystore
|
||||||
check = false;
|
check = false;
|
||||||
|
@ -936,28 +936,28 @@ public class SslContextFactory extends AbstractLifeCycle
|
||||||
{
|
{
|
||||||
// if the keystore has been configured but there is no
|
// if the keystore has been configured but there is no
|
||||||
// truststore configured, use the keystore as the truststore
|
// truststore configured, use the keystore as the truststore
|
||||||
if (_truststoreInputStream == null && _truststorePath == null)
|
if (_trustStoreInputStream == null && _trustStorePath == null)
|
||||||
{
|
{
|
||||||
_truststorePath = _keystorePath;
|
_trustStorePath = _keyStorePath;
|
||||||
_truststoreInputStream = _keystoreInputStream;
|
_trustStoreInputStream = _keyStoreInputStream;
|
||||||
_truststoreType = _keystoreType;
|
_trustStoreType = _keyStoreType;
|
||||||
_truststoreProvider = _keystoreProvider;
|
_trustStoreProvider = _keyStoreProvider;
|
||||||
_truststorePassword = _keystorePassword;
|
_trustStorePassword = _keyStorePassword;
|
||||||
_trustManagerFactoryAlgorithm = _keyManagerFactoryAlgorithm;
|
_trustManagerFactoryAlgorithm = _keyManagerFactoryAlgorithm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// It's the same stream we cannot read it twice, so read it once in memory
|
// It's the same stream we cannot read it twice, so read it once in memory
|
||||||
if (_keystoreInputStream != null && _keystoreInputStream == _truststoreInputStream)
|
if (_keyStoreInputStream != null && _keyStoreInputStream == _trustStoreInputStream)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
IO.copy(_keystoreInputStream, baos);
|
IO.copy(_keyStoreInputStream, baos);
|
||||||
_keystoreInputStream.close();
|
_keyStoreInputStream.close();
|
||||||
|
|
||||||
_keystoreInputStream = new ByteArrayInputStream(baos.toByteArray());
|
_keyStoreInputStream = new ByteArrayInputStream(baos.toByteArray());
|
||||||
_truststoreInputStream = new ByteArrayInputStream(baos.toByteArray());
|
_trustStoreInputStream = new ByteArrayInputStream(baos.toByteArray());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,7 +182,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystorePassword(password);
|
_sslContextFactory.setKeyStorePassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -193,7 +193,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustPassword(String password)
|
public void setTrustPassword(String password)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststorePassword(password);
|
_sslContextFactory.setTrustStorePassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -263,7 +263,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeystore(String keystore)
|
public void setKeystore(String keystore)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystore(keystore);
|
_sslContextFactory.setKeyStore(keystore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -274,7 +274,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeystore()
|
public String getKeystore()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystore();
|
return _sslContextFactory.getKeyStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -285,7 +285,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeystoreType()
|
public String getKeystoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystoreType();
|
return _sslContextFactory.getKeyStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -340,7 +340,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeystoreType(String keystoreType)
|
public void setKeystoreType(String keystoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystoreType(keystoreType);
|
_sslContextFactory.setKeyStoreType(keystoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -395,7 +395,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTruststore()
|
public String getTruststore()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststore();
|
return _sslContextFactory.getTrustStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -406,7 +406,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTruststoreType()
|
public String getTruststoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststoreType();
|
return _sslContextFactory.getTrustStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -461,7 +461,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTruststore(String truststore)
|
public void setTruststore(String truststore)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststore(truststore);
|
_sslContextFactory.setTrustStore(truststore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -472,7 +472,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTruststoreType(String truststoreType)
|
public void setTruststoreType(String truststoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststoreType(truststoreType);
|
_sslContextFactory.setTrustStoreType(truststoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
|
@ -174,7 +174,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeystore()
|
public String getKeystore()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystore();
|
return _sslContextFactory.getKeyStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -185,7 +185,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getKeystoreType()
|
public String getKeystoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getKeystoreType();
|
return _sslContextFactory.getKeyStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -261,7 +261,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTruststore()
|
public String getTruststore()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststore();
|
return _sslContextFactory.getTrustStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -282,7 +282,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public String getTruststoreType()
|
public String getTruststoreType()
|
||||||
{
|
{
|
||||||
return _sslContextFactory.getTruststoreType();
|
return _sslContextFactory.getTrustStoreType();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -428,7 +428,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeystore(String keystore)
|
public void setKeystore(String keystore)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystore(keystore);
|
_sslContextFactory.setKeyStore(keystore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -439,7 +439,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setKeystoreType(String keystoreType)
|
public void setKeystoreType(String keystoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystoreType(keystoreType);
|
_sslContextFactory.setKeyStoreType(keystoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -463,7 +463,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setKeystorePassword(password);
|
_sslContextFactory.setKeyStorePassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -474,7 +474,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTrustPassword(String password)
|
public void setTrustPassword(String password)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststorePassword(password);
|
_sslContextFactory.setTrustStorePassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -539,7 +539,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTruststore(String truststore)
|
public void setTruststore(String truststore)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststore(truststore);
|
_sslContextFactory.setTrustStore(truststore);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -550,7 +550,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setTruststoreType(String truststoreType)
|
public void setTruststoreType(String truststoreType)
|
||||||
{
|
{
|
||||||
_sslContextFactory.setTruststoreType(truststoreType);
|
_sslContextFactory.setTrustStoreType(truststoreType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue