Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

It is fairly easy to set up an unencrypted data flow from (Tested with NiFi 2.0.0-M1 and MiNiFi c++ to NiFi: 0.15.0.)

...

If you want the data flow to use HTTPS, that is a bit more complicated; below is a description of how to do it.  (Tested with NiFi 2.0.0-M1 and MiNiFi c++ 0.15.0.)

Step-by-step guide

  1. Install NiFi.  When you a access https://<hostname>:8443/nifi

...

  1. / the first time in your browser, you will get a "Potential Security Risk Ahead" warning about NiFi's self-signed certificate, but you can click Advanced → Accept the Risk and Continue.


  2. Create a NiFi flow with an Input Port.  Double-click the Input Port, and note its ID (1342ea64-018d-1000-a5cf-7bda6830909b in the screenshot below.)


     Image Added


  3. Create a MiNiFi flow with a Remote Processing Group and an Input Port as shown in this example: https://github.com/apache/nifi-minifi-cpp/blob/main/examples/site_to_site_config.yml.  Update
    • Remote Processing Groups/Input Ports/id and Connections[0]/id to the Input Port ID from NiFi, and
    • Remote Processing Groups/Input Ports/url to the NiFi URL you use to access NiFi in your browser.


  1. Create a self-signed certificate; there are many how-tos on the internet.  Below, we'll assume that your generated files are /opt/certs/agent-cert.pem and /opt/certs/agent-key.pem; the CN of the certificate is "my-agent-ID".

  2. Install NiFi.  When you a access https://<hostname>:8443/nifi/ the first time in your browser, you will get a "Potential Security Risk Ahead" warning about NiFi's self-signed certificate, but you can click Advanced → Accept the Risk and Continue.


  3. Add the following settings to your NiFi installation's nifi.properties file:

    Code Block
    # Site to Site properties
    nifi.remote.input.host=localhost
    nifi.remote.input.secure=true
    nifi.remote.input.socket.port=7777
    nifi.remote.input.http.enabled=true

    Note that the port you configure here, 7777 in this example, will be used internally by the site-to-site communication, but in the MiNiFi config.yml file, you should use the same NiFi address you use in your browser, NOT this site-to-site port.


  4. Export the NiFi certificate from the NiFi trust store, and import the MiNiFi agent certificate into the NiFi trust store: 

    Code Block
    keytool -exportcert -alias nifi-cert -rfc -keystore truststore.p12 > /opt/certs/nifi-cert.pem
    keytool -importcert -alias agent-cert -file /opt/certs/agent-cert.pem -keystore truststore.p12

    keytool will prompt you for the truststore password; you can get this from the nifi.properties file.


  5. Add the agent ID (which is the CN of the agent certificate) as the "Initial User Identity 1" value in the "userGroupProvider" section of authorizers.xml in your NiFi installation:

    Code Block
        <userGroupProvider>
            <identifier>file-user-group-provider</identifier>
            <class>org.apache.nifi.authorization.FileUserGroupProvider</class>
            <property name="Users File">./conf/users.xml</property>
            <property name="Initial User Identity 1">my-agent-ID</property>
        </userGroupProvider>

    and restart NiFi; it will create a new user in users.xml which looks like this:

    Code Block
    <tenants>
        <groups/>
        <users>
            <user identifier="9a889e09-6e86-360a-a324-8f3ee341842a" identity="my-agent-ID"/>
        </users>
    </tenants>


  6. Add authorizations for your user in authorizations.xml in your NiFi installation, copying the user identifier from users.xml:

    Code Block
    <authorizations>
        <policies>
            <policy identifier="1f6ae57a-08bc-11eb-9242-bf69163fde10" resource="/site-to-site" action="R">
              <!-- copy the user identifier from users.xml -->
              <user identifier="9a889e09-6e86-360a-a324-8f3ee341842a"/>
            </policy>
            <policy identifier="282818e0-08bc-11eb-8508-2b51c9d70d42" resource="/site-to-site" action="W">
              <user identifier="9a889e09-6e86-360a-a324-8f3ee341842a"/>
            </policy>
             
            <!-- copy the port identifier from the Input Port in NiFi into the resource string -->
            <policy identifier="f512f796-7afb-4c9f-ab68-b5eaf6d5d0cf" resource="/data-transfer/input-ports/c171f9da-689f-41e2-98c4-9d785c59c306" action="R">
              <user identifier="9a889e09-6e86-360a-a324-8f3ee341842a"/>
            </policy>
            <policy identifier="b4e836ee-d526-4e16-8bf3-ee1d8fa3d5e6" resource="/data-transfer/input-ports/c171f9da-689f-41e2-98c4-9d785c59c306" action="W">
              <user identifier="9a889e09-6e86-360a-a324-8f3ee341842a"/>
            </policy>
      
            <!-- you will also need a pair of policies for resource="/data-transfer/output-ports/..." if you want S2S data transfer from NiFi to MiNiFi -->
       </policies>
    </authorizations> 

...


  1. Restart NiFi again, and test that you can connect to it using https:

    Code Block
    # This should give a large HTML response
    curl -k --key /opt/certs/agent-key.pem --cert /opt/certs/agent-cert.pem https://<hostname>:8443/nifi/
    
    # This should give a JSON response
    curl -k --key /opt/certs/agent-key.pem --cert /opt/certs/agent-cert.pem https://<hostname>:8443/nifi-api/site-to-site/

...


  1. Finally, configure MiNiFi to use secure site-to-site

...

  1. Set up the certificates in minifi.properties

    :

    Code Block
    nifi.remote.input.secure=true
    nifi.security.need.ClientAuth=true
    nifi.security.client.certificate=/opt/certs/agent-cert.pem
    nifi.security.client.private.key=/opt/certs/agent-key.pem
    nifi.security.client.pass.phrase=<key passphrase if any>
    nifi.security.client.ca.certificate=/opt/certs/nifi-cert.pem
    
    # These are not needed
    #nifi.rest.api.user.name=
    #nifi.rest.api.password=
  2. Update the NiFi address in config.yml by changing http  to https and changing the port to 8443 in the Remote Process Group:

    Code Block
    Remote Process Groups:
    - id: 1ca9d943-0175-1000-2188-4d25f7418459
      name: https://<hostname>:8443/nifi/
      url: https://<hostname>:8443/nifi/
      comment: ''
      timeout: 30 secs
      yield period: 10 sec
      transport protocol: RAW
      proxy host: ''
      proxy port: ''
      proxy user: ''
      proxy password: ''
      local network interface: ''
      Input Ports:
      - id: c171f9da-689f-41e2-98c4-9d785c59c306
        name: c171f9da-689f-41e2-98c4-9d785c59c306
        comment: ''
        max concurrent tasks: 1
        use compression: true
      Output Ports: []

    And restart MiNiFi.  Note that the site-to-site port you configured in NiFi will be used for communication, but in the MiNiFi config.yml you need to specify the main NiFi port 8443, NOT the site-to-site port (7777 in the example above).

Content by Label
showLabelsfalse
max5
spacesMINIFI
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel in ("sitetosite","https","tls") and type = "page" and space = "MINIFI"
labelsHTTPS TLS SiteToSite

...

hiddentrue

...


  1. Restart MiNiFi.  It should be sending data to NiFi now.  Congratulations!