Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#643] Add support for client certificate based authentication #744

Merged

Conversation

Alfusainey
Copy link
Contributor

@sophokles73: this patch adds support for client certificate authentication. now the auth providers are known only to the SaslAuthenticator class. i plan to test feature in the ITs.

Signed-off-by: Alfusainey Jallow alf.jallow@gmail.com

@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from df0f093 to 058674f Compare August 1, 2018 14:43
@Alfusainey
Copy link
Contributor Author

@sophokles73: can you please take a look at this?

if (socket.isSsl()) {
LOG.debug("Client connected through a secured port. Ignoring peer certificates (not supported)");
LOG.debug("Client connected through a secured port");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace

try {
peerCertificateChain = socket.sslSession().getPeerCertificates();
clientCertAuthProvider = new X509AuthProvider(credentialsServiceClient, config);
certValidator = new DeviceCertificateValidator();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to create new instances for each device connecting?

@@ -358,6 +359,7 @@ public void testUploadingXnumberOfMessages(final TestContext context) throws Int

final Future<ProtonConnection> result = Future.future();
final ProtonClientOptions options = new ProtonClientOptions();
options.addEnabledSaslMechanism(ProtonSaslPlainImpl.MECH_NAME);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about a test for a client using SASL_EXTERNAL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want to add that later for a device that wants to authenticate using a client certificate. the current test code base does not use any certificate..

SASL_PLAIN is added mainly so that the current ITs passes. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it would be good to have an integration test that uses SASL_EXTERNAL :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW you should rebase so that the Travis build works again ...

@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from 058674f to 775d23f Compare August 2, 2018 15:33
@Alfusainey
Copy link
Contributor Author

I think that it would be good to have an integration test that uses SASL_EXTERNAL :-)

ok, i will include that in this PR

BTW you should rebase so that the Travis build works again ...

just rebased, thanks!

@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from 775d23f to c340b99 Compare August 11, 2018 18:53
@Alfusainey
Copy link
Contributor Author

Alfusainey commented Aug 11, 2018

@sophokles73: patch updated with 899010a. this commit also includes minor refactoring of the HTTP adapter code to reuse its trust options config.

@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from c340b99 to 899010a Compare August 11, 2018 20:33
return null;
}
});
return getTrustOptions();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see why we need to introduce another level of indirection. Can't we simply pull up this method as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you say "pull up", you mean having it as a default implementation for all protocol adapters?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you think that would be a reasonable default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, makes sense

@@ -101,6 +106,7 @@
public static final int MQTT_PORT = Integer.getInteger(PROPERTY_MQTT_PORT, DEFAULT_MQTT_PORT);
public static final String AMQP_HOST = System.getProperty(PROPERTY_AMQP_HOST, DEFAULT_HOST);
public static final int AMQP_PORT = Integer.getInteger(PROPERTY_AMQP_PORT, DEFAULT_AMQP_PORT);
public static final int AMQPS_PORT = Integer.getInteger(PROPERTY_AMQPS_PORT, 4041);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for consistency, can we use a constant for the default AMQPS port as well?

@@ -130,14 +136,14 @@

private final Set<String> tenantsToDelete = new HashSet<>();
private final Map<String, Set<String>> devicesToDelete = new HashMap<>();
private final Vertx vertx;
private static Vertx VERTX;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use upper case naming for constants only

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@sophokles73
Copy link
Contributor

@Alfusainey why doesn't the Travis build succeed?

@Alfusainey
Copy link
Contributor Author

@Alfusainey why doesn't the Travis build succeed?

humm... looks like the vertx thread has been blocked for a long time... am suspecting that it does not directly relate to my changes:

at java.base@10.0.2/java.util.concurrent.CompletableFuture.waitingGet(CompletableFuture.java:1823)
at java.base@10.0.2/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1998)
at app//io.vertx.ext.unit.impl.CompletionImpl.await(CompletionImpl.java:56)
at app//org.eclipse.hono.tests.IntegrationTestSupport.lambda$deleteObjects$4(IntegrationTestSupport.java:206)
at app//org.eclipse.hono.tests.IntegrationTestSupport$$Lambda$245/1193841543.accept(Unknown Source)
at java.base@10.0.2/java.lang.Iterable.forEach(Iterable.java:75)
at app//org.eclipse.hono.tests.IntegrationTestSupport.deleteObjects(IntegrationTestSupport.java:203)
at app//org.eclipse.hono.tests.mqtt.MqttTestBase.lambda$postTest$1(MqttTestBase.java:121)

i think when deleting the temp devices, the call to deletion.await() does not return on time

@Alfusainey
Copy link
Contributor Author

@sophokles73: patch updated with f4ca7ce. now the vertx instance in the IntegrationTestSupport class is not static. i suspect this was failing the java10 build (but am not entirely sure)

@Alfusainey
Copy link
Contributor Author

@sophokles73: something very strange is happening with the jdk10 travis build. it takes longer to run and the MQTT adapter ITs is failing the build. i was thinking that my changes to the IntegrationTestSupport class fails the build but that is not the case

@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from f4ca7ce to 2a6561f Compare August 13, 2018 12:24
@Alfusainey
Copy link
Contributor Author

@sophokles73: i rebased this patch with current master to include 008e20c. hopefully the fix passes the build 👍

@sophokles73
Copy link
Contributor

yeah, let's hope so ...

@Alfusainey
Copy link
Contributor Author

@sophokles73: the build passes 🕺

connection.open();
}
});
if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please split this up into two methods: connectToAdapter(String, String) and connectToAdapter(SelfSignedCertificate) to make it more transparent in the client code which mechanism is used. There is basically no duplicated code so it shouldn't be an issue ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sophokles73 patch updated

@sophokles73
Copy link
Contributor

@Alfusainey can you squash and rebase?

…ation

Signed-off-by: Alfusainey Jallow <alf.jallow@gmail.com>
@Alfusainey Alfusainey force-pushed the amqp-adapter-certificate-auth branch from 17d24e0 to 16a0b14 Compare August 13, 2018 14:52
@Alfusainey
Copy link
Contributor Author

@sophokles73 : done!

@sophokles73 sophokles73 added this to To do in 0.7 via automation Aug 13, 2018
@sophokles73 sophokles73 added this to the 0.7 milestone Aug 13, 2018
@sophokles73 sophokles73 merged commit b293613 into eclipse-hono:master Aug 13, 2018
0.7 automation moved this from To do to Done Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
0.7
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants