Created 01-30-2024 04:37 PM
Good evening, I am having a lot of trouble getting an instance of NiFi running with Mutual TLS. I have different errors depending on whether the effort involves version 1.xx or version 2.xx. I'm hoping to get some help. This is all being attempted via Docker.
My YAML:
```
relevant initial logs when the container boots up:
```
2024-01-31 00:20:34,016 INFO [main] org.eclipse.jetty.server.Server Started @31422ms
2024-01-31 00:20:34,031 INFO [main] org.apache.nifi.web.server.JettyServer NiFi has started. The UI is available at the following URLs:
2024-01-31 00:20:34,031 INFO [main] org.apache.nifi.web.server.JettyServer https://0.0.0.0:9449/nifi
```
Error from the web browser when I attempt to log in (It does successfully prompt me for my .p12 certificate and that seems to work.)
```
<!-- <authorizer>
<identifier>file-provider</identifier>
<class>org.apache.nifi.authorization.FileAuthorizer</class>
<property name="Authorizations File">./conf/authorizations.xml</property>
<property name="Users File">./conf/users.xml</property>
<property name="Initial Admin Identity">'CN=admin'</property>
<property name="Legacy Authorized Users File"></property>
<property name="Node Identity 1"></property>
</authorizer>
```
A printout of the .p12 contents via `keytool`:
```
Keystore type: PKCS12
Keystore provider: SUN
Your keystore contains 1 entry
Alias name: admin
Creation date: Jan 30, 2024
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=admin
Issuer: CN=nifi-ca
```
Pivoting slightly, when I attempt to use the same YAML, but use the following image:
apache/nifi:2.0.0-M1
I get a completely different error. I get an Invalid SNI error.
If there is anything you could do to point me in the right direction, I would greatly appreciate it.
Created 01-31-2024 12:21 PM
Nevermind!!! Problem solved -- setting up the mTLS stuff on NiFi was extremely hard for me. The hardest thing, I think, is just making sure that all of the certs are properly set up and configured. I finally got that done. Key takeaways for me (hopefully making it more simple than the documentation):
1. Because NiFi 2.0.x is now using Java 21 and Jetty 10, it's super persnickety about security, etc. The key issue here is that if you are having 'Invalid SNI' issues (Server Name Indication), it is more likely than not because you don't have your SAN (Subject Alternate Name) set up correctly in your certificates. Bottom-line here, is that Version 2.0.X doesn't allow for ip addresses anymore if you are going to secure the instance. They have to be hostnames.
2. Since you are required to get the hostname issue correct, it could get very complicated. In my case, I was already running a DNS server, so it made it a lot easier, but if you don't have a DNS server, you either need to mod your /etc/hosts file (if you are running NiFi from a local machine), or introduce a DNS server into the mix, or something similar...
3. If you want to have a secured version of NiFi running, and if you want to use it in SINGLE USER mode, that appears to still work ONLY if you access it from the local machine running NiFi, wherein you can use `https://localhost:portnumber/nifi`.
4. However, if you want to use NiFi in mTLS mode (or LDAP, etc.), then you appear to lose the capability of accessing NiFi via `localhost`. So you have to do something to resolve the DNS/Hostname issues. AND critically, your SAN information in your certificates needs to match the hostname, or it won't work properly.
5. Do not make the mistake of thinking you can generate certs without SAN information. This just doesn't seem to work, at all in version 2.0.x
I'm hopeful that this is helpful to someone else. Thanks.
Created 01-31-2024 12:21 PM
Nevermind!!! Problem solved -- setting up the mTLS stuff on NiFi was extremely hard for me. The hardest thing, I think, is just making sure that all of the certs are properly set up and configured. I finally got that done. Key takeaways for me (hopefully making it more simple than the documentation):
1. Because NiFi 2.0.x is now using Java 21 and Jetty 10, it's super persnickety about security, etc. The key issue here is that if you are having 'Invalid SNI' issues (Server Name Indication), it is more likely than not because you don't have your SAN (Subject Alternate Name) set up correctly in your certificates. Bottom-line here, is that Version 2.0.X doesn't allow for ip addresses anymore if you are going to secure the instance. They have to be hostnames.
2. Since you are required to get the hostname issue correct, it could get very complicated. In my case, I was already running a DNS server, so it made it a lot easier, but if you don't have a DNS server, you either need to mod your /etc/hosts file (if you are running NiFi from a local machine), or introduce a DNS server into the mix, or something similar...
3. If you want to have a secured version of NiFi running, and if you want to use it in SINGLE USER mode, that appears to still work ONLY if you access it from the local machine running NiFi, wherein you can use `https://localhost:portnumber/nifi`.
4. However, if you want to use NiFi in mTLS mode (or LDAP, etc.), then you appear to lose the capability of accessing NiFi via `localhost`. So you have to do something to resolve the DNS/Hostname issues. AND critically, your SAN information in your certificates needs to match the hostname, or it won't work properly.
5. Do not make the mistake of thinking you can generate certs without SAN information. This just doesn't seem to work, at all in version 2.0.x
I'm hopeful that this is helpful to someone else. Thanks.