You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/01/13 16:32:24 UTC

[GitHub] [nifi-minifi-cpp] arpadboda opened a new pull request #708: WIP: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

arpadboda opened a new pull request #708: WIP: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708
 
 
   …when NiFi becomes unreachable
   
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] 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:
   - [ ] 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?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### 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.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] bakaid commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
bakaid commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#issuecomment-574213140
 
 
   @szaszm I'm glad, but I am interested in whether it s2s actually works with a NiFi instance over SSL, and I don't believe we have unit/integration tests for that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366255579
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -200,17 +208,12 @@ int16_t TLSSocket::initialize(bool blocking) {
         logger_->log_trace("want read");
         return 0;
       } else {
+        logger_->log_error("SSL socket connect failed to %s %d", requested_hostname_, port_);
+        SSL_free(ssl_);
+        ssl_ = NULL;
+        Socket::closeStream();
 
 Review comment:
   Dtor cleans up anyway, but I was not brave enough to assume that socket objects are never reused. :) 
   
   Simplified cleanup logic anyway. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366318509
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -182,9 +187,19 @@ int16_t TLSSocket::initialize(bool blocking) {
     setNonBlocking();
   logger_->log_trace("Initializing TLSSocket %d", is_server);
   int16_t ret = context_->initialize(is_server);
-  Socket::initialize();
 
-  if (!ret && listeners_ == 0) {
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialize SSL context!");
+    return -1;
+  }
+
+  ret = Socket::initialize();
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialise basic socket for TLS socket");
+    return -1;
 
 Review comment:
   I was wrong about the `logger_` part, since both `Socket` and `TLSSocket` have their own separate private `logger_`s, so move will work.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
bakaid commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366225959
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -182,7 +182,15 @@ int16_t TLSSocket::initialize(bool blocking) {
     setNonBlocking();
   logger_->log_trace("Initializing TLSSocket %d", is_server);
   int16_t ret = context_->initialize(is_server);
-  Socket::initialize();
+
+  if (ret == 0) {
 
 Review comment:
   This control flow is not very readable this way, with `ret` controlling what parts of the code run, sometimes with `== 0`, sometimes with `!= 0` and sometimes with `!ret`. Is there a reason we can't just log and `return -1` each time something fails? I think it would be more readable and would require less nested ifs.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366229841
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -200,17 +208,12 @@ int16_t TLSSocket::initialize(bool blocking) {
         logger_->log_trace("want read");
         return 0;
       } else {
+        logger_->log_error("SSL socket connect failed to %s %d", requested_hostname_, port_);
+        SSL_free(ssl_);
+        ssl_ = NULL;
+        Socket::closeStream();
 
 Review comment:
   These lines for cleanup are present in multiple places in the file. Did you consider extracting to a function or utilizing RAII for cleanup?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366276241
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -182,9 +187,19 @@ int16_t TLSSocket::initialize(bool blocking) {
     setNonBlocking();
   logger_->log_trace("Initializing TLSSocket %d", is_server);
   int16_t ret = context_->initialize(is_server);
-  Socket::initialize();
 
-  if (!ret && listeners_ == 0) {
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialize SSL context!");
+    return -1;
+  }
+
+  ret = Socket::initialize();
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialise basic socket for TLS socket");
+    return -1;
 
 Review comment:
   `context_` is left initialized even if socket initialization has failed. This is not changed behavior, but is it intended?
   
   Speaking about suspicious behavior, `TLSSocket::logger_` will be `nullptr` if the object is initialized via the move ctor.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] arpadboda commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
arpadboda commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#issuecomment-574227346
 
 
   > @arpadboda review fixes look good. Did you test this on Linux as well?
   
   We have a test called "SecureSocketGetTCPTest" (in standard processors extension), which verifies communication via TLS sockets, so together with the Win verification I trust it. 
   What's your opinion? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366255210
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -182,7 +182,15 @@ int16_t TLSSocket::initialize(bool blocking) {
     setNonBlocking();
   logger_->log_trace("Initializing TLSSocket %d", is_server);
   int16_t ret = context_->initialize(is_server);
-  Socket::initialize();
+
+  if (ret == 0) {
 
 Review comment:
   Fair point, simplified a bit. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] szaszm commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
szaszm commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#issuecomment-574208089
 
 
   @bakaid `make`, `make linter` and `make test` resulted in no errors on my linux installation.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] bakaid commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
bakaid commented on issue #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#issuecomment-574229762
 
 
   > > @arpadboda review fixes look good. Did you test this on Linux as well?
   > 
   > We have a test called "SecureSocketGetTCPTest" (in standard processors extension), which verifies communication via TLS sockets, so together with the Win verification I trust it.
   > What's your opinion?
   
   Yep, for the time being it should be OK, but I think it warrants a follow-up task to:
    - test the name resolution failure path in our integration test
    - create a docker test to actually test at least the positive (and preferable negative) cases with a real NiFi instance

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
arpadboda commented on a change in pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708#discussion_r366343751
 
 

 ##########
 File path: libminifi/src/io/tls/TLSSocket.cpp
 ##########
 @@ -182,9 +187,19 @@ int16_t TLSSocket::initialize(bool blocking) {
     setNonBlocking();
   logger_->log_trace("Initializing TLSSocket %d", is_server);
   int16_t ret = context_->initialize(is_server);
-  Socket::initialize();
 
-  if (!ret && listeners_ == 0) {
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialize SSL context!");
+    return -1;
+  }
+
+  ret = Socket::initialize();
+  if (ret != 0) {
+    logger_->log_warn("Failed to initialise basic socket for TLS socket");
+    return -1;
 
 Review comment:
   Unified loggers to only have one.
   Made context init reentrant. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [nifi-minifi-cpp] arpadboda closed pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …

Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #708: MINIFICPP-1118 - MiNiFi C++ on Windows stops running in a secure env …
URL: https://github.com/apache/nifi-minifi-cpp/pull/708
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services