Skip to content

Commit 95ddfef

Browse files
committed
review changes
1 parent 947837a commit 95ddfef

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

libminifi/src/minifi-c.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -616,27 +616,30 @@ void MinifiProcessContextGetDynamicProperties(MinifiProcessContext* context, Min
616616
MinifiStatus MinifiProcessContextGetSslData(MinifiProcessContext* process_context, MinifiStringView controller_service_name,
617617
void (*cb)(void* user_ctx, const MinifiSslData* ssl_data), void* user_ctx) {
618618
gsl_Assert(process_context != MINIFI_NULL);
619-
const auto context = reinterpret_cast<minifi::core::ProcessContext*>(process_context);
620-
const auto name_str = std::string{toStringView(controller_service_name)};
621-
const auto service_shared_ptr = context->getControllerService(name_str, context->getProcessorInfo().getUUID());
622-
if (!service_shared_ptr) { return MINIFI_STATUS_VALIDATION_FAILED; }
623-
if (const auto ssl_context_service = dynamic_cast<minifi::controllers::SSLContextServiceInterface*>(service_shared_ptr.get())) {
624-
const std::string ca_cert_file = ssl_context_service->getCACertificate().string();
625-
const std::string passphrase = ssl_context_service->getPassphrase();
626-
const std::string cert_file = ssl_context_service->getCertificateFile().string();
627-
const std::string private_key_file = ssl_context_service->getPrivateKeyFile().string();
628-
629-
MinifiSslData ssl_data{
630-
.version = 1,
619+
try {
620+
const auto context = reinterpret_cast<minifi::core::ProcessContext*>(process_context);
621+
const auto name_str = std::string{toStringView(controller_service_name)};
622+
const auto service_shared_ptr = context->getControllerService(name_str, context->getProcessorInfo().getUUID());
623+
if (!service_shared_ptr) { return MINIFI_STATUS_VALIDATION_FAILED; }
624+
if (const auto ssl_context_service = dynamic_cast<minifi::controllers::SSLContextServiceInterface*>(service_shared_ptr.get())) {
625+
const std::string ca_cert_file = ssl_context_service->getCACertificate().string();
626+
const std::string passphrase = ssl_context_service->getPassphrase();
627+
const std::string cert_file = ssl_context_service->getCertificateFile().string();
628+
const std::string private_key_file = ssl_context_service->getPrivateKeyFile().string();
629+
630+
MinifiSslData ssl_data{
631631
.ca_certificate_file = minifiStringView(ca_cert_file),
632632
.certificate_file = minifiStringView(cert_file),
633633
.private_key_file = minifiStringView(private_key_file),
634634
.passphrase = minifiStringView(passphrase),
635635
};
636-
cb(user_ctx, &ssl_data);
637-
return MINIFI_STATUS_SUCCESS;
636+
cb(user_ctx, &ssl_data);
637+
return MINIFI_STATUS_SUCCESS;
638+
}
639+
return MINIFI_STATUS_VALIDATION_FAILED;
640+
} catch (...) {
641+
return MINIFI_STATUS_UNKNOWN_ERROR;
638642
}
639-
return MINIFI_STATUS_VALIDATION_FAILED;
640643
}
641644

642645

minifi-api/include/minifi-c/minifi-c.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ extern "C" {
4141
#define MINIFI_REGISTER_EXTENSION_FN MinifiRegisterExtension
4242
#endif
4343

44-
/// To allow the proper usage of SSLContextServices set the MinifiPropertyDefinition::type to MINIFI_SSL_CONTEXT_SERVICE_PROPERTY_TYPE
44+
/// To declare a processor property that expects an SSLContextService,
45+
/// use MINIFI_SSL_CONTEXT_SERVICE_PROPERTY_TYPE in the type field of the property definition (MinifiPropertyDefinition::type)
4546
#define MINIFI_SSL_CONTEXT_SERVICE_PROPERTY_TYPE "org.apache.nifi.minifi.controllers.SSLContextServiceInterface"
4647

4748
enum : uint32_t {
@@ -273,7 +274,6 @@ MinifiStatus MinifiControllerServiceContextGetProperty(MinifiControllerServiceCo
273274
void* user_ctx);
274275

275276
typedef struct MinifiSslData {
276-
uint8_t version;
277277
MinifiStringView ca_certificate_file;
278278
MinifiStringView certificate_file;
279279
MinifiStringView private_key_file;

0 commit comments

Comments
 (0)