}
}
static void configureSsl( SslConnectionFactory sslConnFactory, SecureJettyConfiguration config )
{
SslContextFactory ssl = sslConnFactory.getSslContextFactory();
boolean needBouncyCastle = false;
// KeyStore
String keystoreType = config.keystoreType().get();
String keystorePath = config.keystorePath().get();
String keystorePassword = config.keystorePassword().get();
ssl.setKeyStoreType( keystoreType );
if( "PKCS12".equals( keystoreType ) )
{
ssl.setKeyStoreProvider( "BC" ); // WARN This one needs BouncyCastle on the classpath
needBouncyCastle = true;
}
ssl.setKeyStorePath( keystorePath );
ssl.setKeyStorePassword( keystorePassword );
// Certificate alias
String certAlias = config.certAlias().get();
if( certAlias != null )
{
ssl.setCertAlias( certAlias );
}
// TrustStore
String truststoreType = config.truststoreType().get();
String truststorePath = config.truststorePath().get();
String truststorePassword = config.truststorePassword().get();
if( truststoreType != null && truststorePath != null )
{
ssl.setTrustStoreType( truststoreType );
if( "PKCS12".equals( truststoreType ) )
{
ssl.setTrustStoreProvider( "BC" );
needBouncyCastle = true;
}
ssl.setTrustStorePath( truststorePath );
ssl.setTrustStorePassword( truststorePassword );
}
// Need / Want Client Auth
Boolean want = config.wantClientAuth().get();
if( want != null )
{
ssl.setWantClientAuth( want );
}
Boolean need = config.needClientAuth().get();
if( need != null )
{
ssl.setNeedClientAuth( need );
}
// Algorithms
String secureRandomAlgo = config.secureRandomAlgorithm().get();
if( secureRandomAlgo != null )
{
ssl.setSecureRandomAlgorithm( secureRandomAlgo );
}
String cipherExcludesConfigString = config.excludeCipherSuites().get();
if( cipherExcludesConfigString != null )
{
String[] cipherExcludes = cipherExcludesConfigString.split( COMA );
if( cipherExcludes.length > 0 )
{
ssl.setExcludeCipherSuites( cipherExcludes );
}
}
String cipherIncludesConfigString = config.includeCipherSuites().get();
if( cipherIncludesConfigString != null )
{
String[] cipherIncludes = cipherIncludesConfigString.split( COMA );
if( cipherIncludes.length > 0 )
{
ssl.setIncludeCipherSuites( cipherIncludes );
}
}
// SSL Handling
Boolean cacheSslSessions = config.cacheSslSessions().get();
if( cacheSslSessions != null )
{
ssl.setSessionCachingEnabled( cacheSslSessions );
}
ssl.setRenegotiationAllowed( config.allowRenegotiation().get() );
// Validation Flags
Integer maxCertPathLength = config.maxCertPathLength().get();
if( maxCertPathLength != null )
{
ssl.setMaxCertPathLength( maxCertPathLength );
}
ssl.setValidateCerts( config.validateServerCert().get() );
ssl.setValidatePeerCerts( config.validatePeerCerts().get() );
// Validation CRL
String crlFilePath = config.crlFilePath().get();
if( crlFilePath != null && crlFilePath.length() > 0 )
{
ssl.setCrlPath( crlFilePath );
}
ssl.setEnableCRLDP( config.enableCRLDP().get() );
// Validation OCSP
ssl.setEnableOCSP( config.enableOCSP().get() );
String ocspURL = config.ocspResponderURL().get();
if( ocspURL != null )
{
ssl.setOcspResponderURL( ocspURL );
}
// Load BouncyCastle ?
if( needBouncyCastle )
{