You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by alopresto <gi...@git.apache.org> on 2018/02/10 01:08:12 UTC
[GitHub] nifi pull request #2463: NIFI-3367 Enforced minimum length of shared secret ...
GitHub user alopresto opened a pull request:
https://github.com/apache/nifi/pull/2463
NIFI-3367 Enforced minimum length of shared secret in TLS toolkit client/server mode
Thank you for submitting a contribution to Apache NiFi.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [x] Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [x] Has your PR been rebased against the latest commit within the target branch (typically master)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [x] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
- [x] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/alopresto/nifi NIFI-3367
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/nifi/pull/2463.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2463
----
commit 79a0aafe51a6d806ef3952650139ebbcd007e274
Author: Lori Buettner <lo...@...>
Date: 2018-02-10T00:46:33Z
NIFI-3367 Added token length check and unit test.
commit 5d9680a3333513bc9e28067eed45b07823f250c7
Author: Lori Buettner <lo...@...>
Date: 2018-02-10T01:04:58Z
NIFI-3367 Resolved failing unit tests.
----
---
[GitHub] nifi issue #2463: NIFI-3367 Enforced minimum length of shared secret in TLS ...
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the issue:
https://github.com/apache/nifi/pull/2463
Ran the toolkit in client/server mode. Both rejected a token < 16 bytes with an informative error message. With a long token, the process succeeded.
Ran `contrib-check` and all tests pass. +1, merging.
---
[GitHub] nifi pull request #2463: NIFI-3367 Enforced minimum length of shared secret ...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/nifi/pull/2463
---
[GitHub] nifi pull request #2463: NIFI-3367 Enforced minimum length of shared secret ...
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2463#discussion_r167382434
--- Diff: nifi-toolkit/nifi-toolkit-tls/src/test/java/org/apache/nifi/toolkit/tls/util/TlsHelperTest.java ---
@@ -171,6 +172,43 @@ private Date inFuture(int days) {
return new Date(System.currentTimeMillis() + TimeUnit.DAYS.toMillis(days));
}
+ @Test
+ public void testTokenLengthInCalculateHmac() throws CertificateException, NoSuchAlgorithmException {
+ List<String> badTokens = new ArrayList<>();
+ List<String> goodTokens = new ArrayList<>();
+ badTokens.add(null);
+ badTokens.add("");
+ badTokens.add("123");
+ goodTokens.add("0123456789abcdefghijklm");
+ goodTokens.add("0123456789abcdef");
+
+ String dn = "CN=testDN,O=testOrg";
+ X509Certificate x509Certificate = CertificateUtils.generateSelfSignedX509Certificate(TlsHelper.generateKeyPair(keyPairAlgorithm, keySize), dn, signingAlgorithm, days);
+ PublicKey pubKey = x509Certificate.getPublicKey();
+
+ for (String token : badTokens) {
+ try {
+ TlsHelper.calculateHMac(token, pubKey);
+ fail("HMAC was calculated with a token that was too short.");
+ } catch (GeneralSecurityException e) {
+ assertEquals("Token does not meet minimum size of 16 bytes.", e.getMessage());
+ } catch (IllegalArgumentException e) {
+ assertEquals("Token cannot be null", e.getMessage());
+ }
+ }
+
+ for (String token : goodTokens) {
+ try {
+ byte[] hmac = TlsHelper.calculateHMac(token, pubKey);
+ assertTrue("HMAC length ok", hmac.length > 0);
+ } catch (GeneralSecurityException e) {
+ fail(e.getMessage());
+ }
+ }
+
--- End diff --
Please remove unnecessary whitespace.
---
[GitHub] nifi issue #2463: NIFI-3367 Enforced minimum length of shared secret in TLS ...
Posted by alopresto <gi...@git.apache.org>.
Github user alopresto commented on the issue:
https://github.com/apache/nifi/pull/2463
Reviewing...
---