Skip to content

Conversation

@alopresto
Copy link
Contributor

This PR resolves an issue where cluster communications were failing when the node sent a heartbeat without a client certificate chain because nifi.security.needClientAuth was set to false on the NCM. Even though the TLS negotiation did not require or expect a client certificate and the handshake was successful, the NiFi code in SocketProtocolListener immediately attempted to determine the incoming node's DN from the certificate, which was missing, and thus SSLSocketImpl threw an SSLPeerNotVerifiedException saying "peer not authenticated".

With this patch, the NCM will now respect the needClientAuth setting when attempting to extract the node DN.

This PR is targeted to the 0.x branch as this is where the issue was discovered and does not merge cleanly with the master branch. These changes will need to be selectively merged to the master branch.

@Test
void testShouldDetermineClientAuthStatusFromSocket() {
// Arrange
SSLSocket needSocket = [getNeedClientAuth: { -> true }] as SSLSocket
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm seeing some Java 8 stuff (Lambdas, e.g) but this PR is against 0.x, which needs Java 7 language target

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, I should've noticed these were Groovy coercions.
<-- embarrassed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with Matt offline, but these are standard Groovy map coercions, not lambdas. Running a local check against Java 7 to ensure no Java 8 features were introduced.

@mattyb149
Copy link
Contributor

+1 LGTM, built and ran with Java 7 and 8 on 0.x branch. Mind squashing the commits? Then I'll merge to 0.x and master, thanks!

@alopresto
Copy link
Contributor Author

Squashing and will push. Thanks @mattyb149 .

</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed this the first time, a duplicate definition of this artifact. Gives the following warning upon build:

[WARNING] Some problems were encountered while building the effective model for org.apache.nifi:nifi-security-utils🫙1.0.0-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.bouncycastle:bcpkix-jdk15on:jar -> duplicate declaration of version (?) @ org.apache.nifi:nifi-security-utils:[unknown-version], /Users/mburgess/git-apache/nifi/nifi-commons/nifi-security-utils/pom.xml, line 43, column 21

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch Matt. Fixed, squashed, and pushed.

…ertificates would fail even if needClientAuth set to false.

Fixed IDE setting for import wildcarding on Groovy files. (+4 squashed commits)
Squashed commits:
[4c3b174] NIFI-1981 Lowered logging level of client auth setting on cluster connection receive.
[b50f473] NIFI-1981 Finished logic to suppress exception on missing client certificates when clientAuth is set to WANT.
Added unit tests for CertificateUtil methods.
[ace35a2] NIFI-1981 Added test scope dependency on BouncyCastle and BC PKIX modules for CertificateUtils tests.
[2c463d1] NIFI-1981 Added ClientAuth enum and CertificateUtil methods to extract this setting from an SSLSocket.
Added logic to compare X509Certificate DNs regardless of RDN element order.
Added logic to suppress peer certificate exceptions when client authentication is not required.
Removed duplicate dependency in pom.xml.
@alopresto
Copy link
Contributor Author

@mattyb149 merged to 0.x.

@alopresto alopresto closed this Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants