use of org.mule.runtime.core.privileged.security.tls.TlsConfiguration in project mule by mulesoft.
the class TlsConfigurationTestCase method testExceptionOnInvalidKeyAlias.
@Test
public void testExceptionOnInvalidKeyAlias() throws Exception {
URL keystoreUrl = getClass().getClassLoader().getResource("serverKeystore");
File keystoreFile = new File(keystoreUrl.toURI());
TlsConfiguration config = new TlsConfiguration(keystoreFile.getAbsolutePath());
config.setKeyStorePassword("mulepassword");
config.setKeyPassword("mulepassword");
config.setKeyAlias("this_key_does_not_exist_in_the_keystore");
try {
config.initialise(false, JSSE_NAMESPACE);
} catch (CreateException ce) {
assertTrue(ce.getCause() instanceof IllegalStateException);
}
}
use of org.mule.runtime.core.privileged.security.tls.TlsConfiguration in project mule by mulesoft.
the class TlsConfigurationTestCase method testSecurityModelProperty.
@Test
public void testSecurityModelProperty() throws Exception {
String previousSecurityModel = SecurityUtils.getSecurityModel();
System.setProperty(MuleProperties.MULE_SECURITY_SYSTEM_PROPERTY, TEST_SECURITY_MODEL);
File file = createConfigFile(TEST_SECURITY_MODEL, "enabledCipherSuites=TEST");
try {
TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE);
tlsConfiguration.initialise(true, JSSE_NAMESPACE);
assertArrayEquals(new String[] { "TEST" }, tlsConfiguration.getEnabledCipherSuites());
} finally {
System.setProperty(MuleProperties.MULE_SECURITY_SYSTEM_PROPERTY, previousSecurityModel);
file.delete();
}
}
use of org.mule.runtime.core.privileged.security.tls.TlsConfiguration in project mule by mulesoft.
the class TlsConfigurationTestCase method testCipherSuitesFromConfigFile.
@Test
public void testCipherSuitesFromConfigFile() throws Exception {
File configFile = createDefaultConfigFile();
try {
TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE);
tlsConfiguration.initialise(true, JSSE_NAMESPACE);
SSLSocket socket = (SSLSocket) tlsConfiguration.getSocketFactory().createSocket();
SSLServerSocket serverSocket = (SSLServerSocket) tlsConfiguration.getServerSocketFactory().createServerSocket();
assertArrayEquals(new String[] { SUPPORTED_CIPHER_SUITE }, socket.getEnabledCipherSuites());
assertArrayEquals(new String[] { SUPPORTED_CIPHER_SUITE }, serverSocket.getEnabledCipherSuites());
} finally {
configFile.delete();
}
}
use of org.mule.runtime.core.privileged.security.tls.TlsConfiguration in project mule by mulesoft.
the class TlsConfigurationTestCase method overrideDefaultProtocolFromConfigFile.
@Test
public void overrideDefaultProtocolFromConfigFile() throws Exception {
File configFile = createDefaultProtocolConfigFile();
try {
TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE);
tlsConfiguration.setSslType("TLSv1.2");
tlsConfiguration.initialise(true, JSSE_NAMESPACE);
SSLSocketFactory socketFactory = tlsConfiguration.getSocketFactory();
SSLContext sslContext = SSLContext.getInstance(SUPPORTED_PROTOCOL);
sslContext.init(null, null, null);
SSLSocketFactory protocolSocketFactory = sslContext.getSocketFactory();
assertThat(socketFactory.getDefaultCipherSuites(), not(arrayWithSize(protocolSocketFactory.getDefaultCipherSuites().length)));
} finally {
configFile.delete();
}
}
use of org.mule.runtime.core.privileged.security.tls.TlsConfiguration in project mule by mulesoft.
the class TlsConfigurationTestCase method testProtocolsFromConfigFile.
@Test
public void testProtocolsFromConfigFile() throws Exception {
File configFile = createDefaultConfigFile();
try {
TlsConfiguration tlsConfiguration = new TlsConfiguration(DEFAULT_KEYSTORE);
tlsConfiguration.initialise(true, JSSE_NAMESPACE);
SSLSocket socket = (SSLSocket) tlsConfiguration.getSocketFactory().createSocket();
SSLServerSocket serverSocket = (SSLServerSocket) tlsConfiguration.getServerSocketFactory().createServerSocket();
assertArrayEquals(new String[] { SUPPORTED_PROTOCOL }, socket.getEnabledProtocols());
assertArrayEquals(new String[] { SUPPORTED_PROTOCOL }, serverSocket.getEnabledProtocols());
} finally {
configFile.delete();
}
}
Aggregations