lordgamez commented on a change in pull request #1216:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1216#discussion_r758156339



##########
File path: extensions/opc/src/opcbase.cpp
##########
@@ -84,45 +83,41 @@ namespace processors {
 
     auto certificatePathRes = context->getProperty(CertificatePath.getName(), 
certpath_);
     auto keyPathRes = context->getProperty(KeyPath.getName(), keypath_);
-    auto trustedPathRes = context->getProperty(TrustedPath.getName(), 
trustpath_);
-    if (certificatePathRes != keyPathRes || keyPathRes != trustedPathRes) {
-      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "All or none of Certificate 
path, Key path and Trusted server certificate path should be provided!");
+    context->getProperty(TrustedPath.getName(), trustpath_);
+    if (certificatePathRes != keyPathRes) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "All or none of Certificate 
path and Key path should be provided!");
     }
 
-    if (!password_.empty() && (certpath_.empty() || keypath_.empty() || 
trustpath_.empty() || applicationURI_.empty())) {
-      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Certificate path, Key path, 
Trusted server certificate path and Application URI must be provided in case 
Password is provided!");

Review comment:
       On second thought it should be readded only with a bit of modification 
as the trustpath is not mandatory in this case.

##########
File path: extensions/opc/src/opcbase.cpp
##########
@@ -84,45 +83,41 @@ namespace processors {
 
     auto certificatePathRes = context->getProperty(CertificatePath.getName(), 
certpath_);
     auto keyPathRes = context->getProperty(KeyPath.getName(), keypath_);
-    auto trustedPathRes = context->getProperty(TrustedPath.getName(), 
trustpath_);
-    if (certificatePathRes != keyPathRes || keyPathRes != trustedPathRes) {
-      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "All or none of Certificate 
path, Key path and Trusted server certificate path should be provided!");
+    context->getProperty(TrustedPath.getName(), trustpath_);
+    if (certificatePathRes != keyPathRes) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "All or none of Certificate 
path and Key path should be provided!");
     }
 
-    if (!password_.empty() && (certpath_.empty() || keypath_.empty() || 
trustpath_.empty() || applicationURI_.empty())) {
-      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Certificate path, Key path, 
Trusted server certificate path and Application URI must be provided in case 
Password is provided!");
+    if (certpath_.empty()) {
+      return;
+    }
+    if (applicationURI_.empty()) {
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Application URI must be 
provided if Certificate path is provided!");
     }
 
-    if (!certpath_.empty()) {
-      if (applicationURI_.empty()) {
-        throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Application URI must be 
provided if Certificate path is provided!");
-      }
+    std::ifstream input_cert(certpath_, std::ios::binary);
+    if (input_cert.good()) {
+      certBuffer_ = 
std::vector<char>(std::istreambuf_iterator<char>(input_cert), {});
+    }
+    std::ifstream input_key(keypath_, std::ios::binary);
+    if (input_key.good()) {
+      keyBuffer_ = 
std::vector<char>(std::istreambuf_iterator<char>(input_key), {});
+    }
 
-      std::ifstream input_cert(certpath_, std::ios::binary);
-      if (input_cert.good()) {
-        certBuffer_ = 
std::vector<char>(std::istreambuf_iterator<char>(input_cert), {});
-      }
-      std::ifstream input_key(keypath_, std::ios::binary);
-      if (input_key.good()) {
-        keyBuffer_ = 
std::vector<char>(std::istreambuf_iterator<char>(input_key), {});
-      }
+    if (certBuffer_.empty()) {
+      auto error_msg = utils::StringUtils::join_pack("Failed to load cert from 
path: ", certpath_);
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, error_msg);
+    }
+    if (keyBuffer_.empty()) {
+      auto error_msg = utils::StringUtils::join_pack("Failed to load key from 
path: ", keypath_);
+      throw Exception(PROCESS_SCHEDULE_EXCEPTION, error_msg);
+    }
 
-      trustBuffers_.emplace_back();
+    if (!trustpath_.empty()) {
       std::ifstream input_trust(trustpath_, std::ios::binary);
       if (input_trust.good()) {
-        trustBuffers_[0] = 
std::vector<char>(std::istreambuf_iterator<char>(input_trust), {});
-      }
-
-      if (certBuffer_.empty()) {
-        auto error_msg = utils::StringUtils::join_pack("Failed to load cert 
from path: ", certpath_);
-        throw Exception(PROCESS_SCHEDULE_EXCEPTION, error_msg);
-      }
-      if (keyBuffer_.empty()) {
-        auto error_msg = utils::StringUtils::join_pack("Failed to load key 
from path: ", keypath_);
-        throw Exception(PROCESS_SCHEDULE_EXCEPTION, error_msg);
-      }
-
-      if (trustBuffers_[0].empty()) {
+        
trustBuffers_.push_back(std::vector<char>(std::istreambuf_iterator<char>(input_trust),
 {}));
+      } else {

Review comment:
       Yes it was intentional because the OPC UA server does not require 
trusted paths to be defined for a secure connection only the key and the 
certificate that are mandatory, trusted certificates are optional.

##########
File path: thirdparty/open62541/open62541.patch
##########
@@ -11,11 +11,20 @@ index d426e1da..5f1a4044 100644
  find_package(PythonInterp REQUIRED)
  find_package(Git)
  include(AssignSourceGroup)
-@@ -416,17 +416,17 @@ if(NOT UA_COMPILE_AS_CXX AND (CMAKE_COMPILER_IS_GNUCC OR 
"x${CMAKE_C_COMPILER_ID
+@@ -526,7 +526,7 @@ if(NOT UA_FORCE_CPP AND (CMAKE_COMPILER_IS_GNUCC OR 
"x${CMAKE_C_COMPILER_ID}" ST
+     check_add_cc_flag("-Wall")      # Warnings
+     check_add_cc_flag("-Wextra")    # More warnings
+     check_add_cc_flag("-Wpedantic") # Standard compliance
+-    check_add_cc_flag("-Werror")    # All warnings are errors
++    # check_add_cc_flag("-Werror")    # All warnings are errors
+ 
+     check_add_cc_flag("-Wno-static-in-inline") # Clang doesn't like the use 
of static inline methods inside static inline methods

Review comment:
       Actually I did not add this line, it was changed when updated to the 
latest version of OPC UA library. My change was only to remove the -Werror flag.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to