-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARTEMIS-4528 tls, add support for PEM key store type
- Loading branch information
Showing
49 changed files
with
495 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
...ion-tests/src/test/java/org/apache/activemq/artemis/tests/integration/ssl/SslPEMTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.activemq.artemis.tests.integration.ssl; | ||
|
||
import java.lang.management.ManagementFactory; | ||
import java.net.URL; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException; | ||
import org.apache.activemq.artemis.api.core.Message; | ||
import org.apache.activemq.artemis.api.core.QueueConfiguration; | ||
import org.apache.activemq.artemis.api.core.SimpleString; | ||
import org.apache.activemq.artemis.api.core.TransportConfiguration; | ||
import org.apache.activemq.artemis.api.core.client.ActiveMQClient; | ||
import org.apache.activemq.artemis.api.core.client.ClientConsumer; | ||
import org.apache.activemq.artemis.api.core.client.ClientMessage; | ||
import org.apache.activemq.artemis.api.core.client.ClientProducer; | ||
import org.apache.activemq.artemis.api.core.client.ClientSession; | ||
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; | ||
import org.apache.activemq.artemis.api.core.client.ServerLocator; | ||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; | ||
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; | ||
import org.apache.activemq.artemis.core.security.Role; | ||
import org.apache.activemq.artemis.core.server.ActiveMQServer; | ||
import org.apache.activemq.artemis.core.server.ActiveMQServers; | ||
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; | ||
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager; | ||
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; | ||
import org.apache.activemq.artemis.tests.integration.security.SecurityTest; | ||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; | ||
import org.apache.activemq.artemis.utils.RandomUtil; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* See the tests/security-resources/build.sh script for details on the security resources used. | ||
*/ | ||
public class SslPEMTest extends ActiveMQTestBase { | ||
|
||
static { | ||
String path = System.getProperty("java.security.auth.login.config"); | ||
if (path == null) { | ||
URL resource = SecurityTest.class.getClassLoader().getResource("login.config"); | ||
if (resource != null) { | ||
path = resource.getFile(); | ||
System.setProperty("java.security.auth.login.config", path); | ||
} | ||
} | ||
} | ||
|
||
private TransportConfiguration tc; | ||
private SimpleString QUEUE; | ||
|
||
@Test | ||
public void testPemKeyAndTrustStore() throws Exception { | ||
|
||
tc.getParams().put(TransportConstants.SSL_ENABLED_PROP_NAME, true); | ||
tc.getParams().put(TransportConstants.KEYSTORE_TYPE_PROP_NAME, "PEM"); | ||
tc.getParams().put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "client-key-cert.pem"); | ||
tc.getParams().put(TransportConstants.PORT_PROP_NAME, "61617"); | ||
|
||
ServerLocator producerLocator; | ||
ClientSessionFactory producerSessionFactory; | ||
ClientSession producerSession; | ||
|
||
// first without trust store | ||
try { | ||
producerLocator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); | ||
producerSessionFactory = createSessionFactory(producerLocator); | ||
producerSessionFactory.createSession(false, true, true); | ||
} catch (ActiveMQNotConnectedException expected) { | ||
} | ||
|
||
// configure trust | ||
tc.getParams().put(TransportConstants.TRUSTSTORE_TYPE_PROP_NAME, "PEM"); | ||
tc.getParams().put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "server-ca-cert.pem"); | ||
producerLocator = addServerLocator(ActiveMQClient.createServerLocatorWithoutHA(tc)); | ||
producerSessionFactory = createSessionFactory(producerLocator); | ||
|
||
producerSession = producerSessionFactory.createSession(false, true, true); | ||
|
||
producerSession.createQueue(new QueueConfiguration(QUEUE).setDurable(false)); | ||
ClientProducer producer = producerSession.createProducer(QUEUE); | ||
|
||
ClientMessage message = createTextMessage(producerSession, RandomUtil.randomString()); | ||
producer.send(message); | ||
|
||
ServerLocator consumerLocator = addServerLocator(ActiveMQClient.createServerLocator("tcp://localhost:61616")); | ||
ClientSessionFactory consumerSessionFactory = createSessionFactory(consumerLocator); | ||
ClientSession consumerSession = consumerSessionFactory.createSession("consumer", "consumerPassword", false, true, true, consumerLocator.isPreAcknowledge(), consumerLocator.getAckBatchSize()); | ||
ClientConsumer consumer = consumerSession.createConsumer(QUEUE); | ||
consumerSession.start(); | ||
|
||
Message m = consumer.receive(1000); | ||
Assert.assertNotNull(m); | ||
} | ||
|
||
@Override | ||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
QUEUE = new SimpleString(getName()); | ||
|
||
Map<String, Object> params = new HashMap<>(); | ||
params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true); | ||
params.put(TransportConstants.KEYSTORE_TYPE_PROP_NAME, "PEMCFG"); | ||
params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "server-pem-props-config.txt"); | ||
params.put(TransportConstants.TRUSTSTORE_TYPE_PROP_NAME, "PEM"); | ||
params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "client-ca-cert.pem"); | ||
params.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true); | ||
params.put(TransportConstants.PORT_PROP_NAME, "61617"); | ||
ConfigurationImpl config = createBasicConfig(); | ||
config.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params)); | ||
config.addAcceptorConfiguration(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY)); | ||
config.setSecurityEnabled(true); | ||
|
||
ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager("DualAuthenticationPropertiesLogin", "DualAuthenticationCertLogin"); | ||
ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, ManagementFactory.getPlatformMBeanServer(), securityManager, false)); | ||
|
||
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository(); | ||
Role sendRole = new Role("producers", true, false, true, false, true, false, false, false, true, false); | ||
Role receiveRole = new Role("consumers", false, true, false, false, false, false, false, false, false, false); | ||
Set<Role> roles = new HashSet<>(); | ||
roles.add(sendRole); | ||
roles.add(receiveRole); | ||
securityRepository.addMatch(QUEUE.toString(), roles); | ||
|
||
server.start(); | ||
waitForServerToStart(server); | ||
tc = new TransportConfiguration(NETTY_CONNECTOR_FACTORY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDcDCCAligAwIBAgIEJbym6DANBgkqhkiG9w0BAQsFADBfMREwDwYDVQQKEwhB | ||
Y3RpdmVNUTEQMA4GA1UECxMHQXJ0ZW1pczE4MDYGA1UEAxMvQWN0aXZlTVEgQXJ0 | ||
ZW1pcyBDbGllbnQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwIBcNMjMxMjA3MTY0 | ||
ODUyWhgPMzAyMzA0MDkxNjQ4NTJaMF8xETAPBgNVBAoTCEFjdGl2ZU1RMRAwDgYD | ||
VQQLEwdBcnRlbWlzMTgwNgYDVQQDEy9BY3RpdmVNUSBBcnRlbWlzIENsaWVudCBD | ||
ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC | ||
AQoCggEBAIaj9LoncxRCfTayohTMSqWCutkAXE8rTDKbpmrTt3RMkmqJw2sO3tn0 | ||
CZkcfkf+1eXsJHRoH9uhUZI7Cc+vGFCfWF9RTi4aCjYFtTXmb0FAsOl1TTRjDgWb | ||
eyUYI25KpVBz57JD3GlFlFo0tLQkc/C1QWU3dlpU5INh5vo/1Si4hrVSX8/Hun8q | ||
daZg4bjfUGnNa0H5nPfkCaZjAamAKp6L50e0cLS4PQCPhVMdH6uU2CEJDxNURN3i | ||
tD6z3YJReFpxNM3HmDwLgUxQcvByQ60Qc90aUihKqXKj8rlFJn76d/kkH3xj2n5t | ||
msY4/GNxh+P0W8whH4C7uglo/vSaDbMCAwEAAaMyMDAwHQYDVR0OBBYEFKUM1JFb | ||
FBp0jlZ9Cb6UbaPQAOr7MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD | ||
ggEBAFmb6rDuirRpEpO/+jXRqq3A4gqMW4Qbjqb61pIQyNim+0Z+RDwQn4nfnZxY | ||
CaAlRiwg7Ihr85brwHcAC2YG/ir3AEcY70r15xIFCiRkDo47r8cXhTAiQfVBjd1j | ||
m1Bo1w1Sae/Vhe/Jryuqz7C+lXads6xWr9x+RoKb9IDgRhz6aVUBQfkyuusm3D+c | ||
RN7i3IRD2ypf1dEAH51+n+U3gEtWbztA2R1MFCGq/pWfEbMaI7fkBu77h6e/Okwq | ||
dNAbXMYlKvv/BgkmzPvHWtepa/1vWZmyC1t0Oo3jNBrUMPCrkQwHbSMl9vMQwICJ | ||
LnIXqz1dSY/M11jjOVS8ZoZ0gdE= | ||
-----END CERTIFICATE----- |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
Bag Attributes | ||
friendlyName: client-ca | ||
localKeyID: 54 69 6D 65 20 31 36 32 38 32 30 33 36 33 37 31 38 36 | ||
localKeyID: 54 69 6D 65 20 31 37 30 31 39 36 37 37 33 32 36 35 35 | ||
Key Attributes: <No Attributes> | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEv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rtprfDjPd4D62RIOHJVPmlxApmiqr6m9t7LMhbWtAoGBAITtzDRoOwDGwA3UB3cR | ||
ObFmijIzfjqxU0Q3T4QZe6gbLE1ExEdXMcMX/JhU6n4LJ/FcAf7/dwm15xqIQmzK | ||
iqmRb8Nnk0li1pUxusZ2jt5W4DGmafim7XdzDaLpSukws51Zj7WpiFDBBaQbww7k | ||
0yWnt8ORrQTF6/2ZESuODqK0 | ||
-----END PRIVATE KEY----- |
Oops, something went wrong.