adamdebreceni commented on code in PR #1370:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1370#discussion_r931015557


##########
libminifi/src/utils/net/Ssl.cpp:
##########
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "utils/net/Ssl.h"
+#include "controllers/SSLContextService.h"
+
+namespace org::apache::nifi::minifi::utils::net {
+
+std::optional<utils::net::SslData> getSslData(const core::ProcessContext& 
context, const core::Property& ssl_prop, const 
std::shared_ptr<core::logging::Logger>& logger) {
+  auto getSslContextService = [&]() -> 
std::shared_ptr<minifi::controllers::SSLContextService> {
+    if (auto ssl_service_name = context.getProperty(ssl_prop); 
ssl_service_name && !ssl_service_name->empty()) {
+      if (auto service = context.getControllerService(*ssl_service_name)) {
+        if (auto ssl_service = 
std::dynamic_pointer_cast<org::apache::nifi::minifi::controllers::SSLContextService>(service))
 {
+          return ssl_service;
+        } else {
+          logger->log_warn("SSL Context Service property is set to '%s', but 
it is not a valid SSLContextService.", *ssl_service_name);
+        }
+      } else {
+        logger->log_warn("SSL Context Service property is set to '%s', but the 
controller service could not be found.", *ssl_service_name);
+      }
+    } else {
+      logger->log_warn("No valid SSL Context Service property is set.");
+    }
+    return nullptr;
+  };
+
+  if (auto service = getSslContextService()) {
+    auto ssl_service = 
std::static_pointer_cast<minifi::controllers::SSLContextService>(service);

Review Comment:
   `getSslContextService` seems to return a 
`std::shared_ptr<SSLContextService>`, the static cast might not be necessary 



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to