alopresto commented on issue #3960: NIFI-6978 Added code and unit test to throw 
IllegalArgumentException …
URL: https://github.com/apache/nifi/pull/3960#issuecomment-572761443
 
 
   Did a build, populated a sensitive configuration value, ran the encrypt 
config toolkit to encrypt it, and then manually removed the delimiter from the 
encrypted value. Tried to start NiFi and got a better error message that 
identified the bad value. LGTM, +1. 
   
   ```
   2020-01-09 13:17:04,352 INFO [main] org.apache.nifi.NiFi Launching NiFi...
   2020-01-09 13:17:04,404 INFO [main] org.apache.nifi.NiFi Now overwriting 
file in 
/Users/alopresto/Workspace/nifi/nifi-assembly/target/nifi-1.11.0-SNAPSHOT-bin/nifi-1.11.0-SNAPSHOT/./conf/sensitive.key
   2020-01-09 13:17:04,405 INFO [main] org.apache.nifi.NiFi Overwriting key 
material with pad: 
ce27dd0d45ec625afae153976ec897e42a8ac7082d9fdb18fb5c94502ec0d35f
   2020-01-09 13:17:04,405 INFO [main] org.apache.nifi.NiFi Removing/unlinking 
file: 
/Users/alopresto/Workspace/nifi/nifi-assembly/target/nifi-1.11.0-SNAPSHOT-bin/nifi-1.11.0-SNAPSHOT/./conf/sensitive.key
   2020-01-09 13:17:04,405 INFO [main] org.apache.nifi.NiFi Read property 
protection key from key file provided by bootstrap process
   2020-01-09 13:17:04,540 INFO [main] org.apache.nifi.security.kms.CryptoUtils 
Determined default nifi.properties path to be 
'/Users/alopresto/Workspace/nifi/nifi-assembly/target/nifi-1.11.0-SNAPSHOT-bin/nifi-1.11.0-SNAPSHOT/./conf/nifi.properties'
   2020-01-09 13:17:04,542 INFO [main] o.a.nifi.properties.NiFiPropertiesLoader 
Loaded 159 properties from 
/Users/alopresto/Workspace/nifi/nifi-assembly/target/nifi-1.11.0-SNAPSHOT-bin/nifi-1.11.0-SNAPSHOT/./conf/nifi.properties
   2020-01-09 13:17:05,020 INFO [main] o.a.n.properties.ProtectedNiFiProperties 
There are 1 protected properties of 5 sensitive properties (100%)
   2020-01-09 13:17:05,022 WARN [main] o.a.n.properties.ProtectedNiFiProperties 
Failed to unprotect 'nifi.sensitive.props.key'
   org.apache.nifi.properties.SensitivePropertyProtectionException: Error 
unprotecting value for nifi.sensitive.props.key
        at 
org.apache.nifi.properties.ProtectedNiFiProperties.unprotectValue(ProtectedNiFiProperties.java:528)
        at 
org.apache.nifi.properties.ProtectedNiFiProperties.getUnprotectedProperties(ProtectedNiFiProperties.java:343)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.load(NiFiPropertiesLoader.java:209)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.load(NiFiPropertiesLoader.java:223)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.loadDefault(NiFiPropertiesLoader.java:130)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.get(NiFiPropertiesLoader.java:241)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.nifi.NiFi.initializeProperties(NiFi.java:339)
        at 
org.apache.nifi.NiFi.convertArgumentsToValidatedNiFiProperties(NiFi.java:312)
        at 
org.apache.nifi.NiFi.convertArgumentsToValidatedNiFiProperties(NiFi.java:308)
        at org.apache.nifi.NiFi.main(NiFi.java:300)
   Caused by: java.lang.IllegalArgumentException: The cipher text does not 
contain the delimiter || -- it should be of the form Base64(IV) || 
Base64(cipherText)
        at 
org.apache.nifi.properties.AESSensitivePropertyProvider.unprotect(AESSensitivePropertyProvider.java:217)
        at 
org.apache.nifi.properties.ProtectedNiFiProperties.unprotectValue(ProtectedNiFiProperties.java:524)
        ... 13 common frames omitted
   2020-01-09 13:17:05,023 ERROR [main] org.apache.nifi.NiFi Failure to launch 
NiFi due to java.lang.IllegalArgumentException: There was an issue decrypting 
protected properties
   java.lang.IllegalArgumentException: There was an issue decrypting protected 
properties
        at org.apache.nifi.NiFi.initializeProperties(NiFi.java:344)
        at 
org.apache.nifi.NiFi.convertArgumentsToValidatedNiFiProperties(NiFi.java:312)
        at 
org.apache.nifi.NiFi.convertArgumentsToValidatedNiFiProperties(NiFi.java:308)
        at org.apache.nifi.NiFi.main(NiFi.java:300)
   Caused by: org.apache.nifi.properties.SensitivePropertyProtectionException: 
Failed to unprotect key nifi.sensitive.props.key
        at 
org.apache.nifi.properties.ProtectedNiFiProperties.getUnprotectedProperties(ProtectedNiFiProperties.java:358)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.load(NiFiPropertiesLoader.java:209)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.load(NiFiPropertiesLoader.java:223)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.loadDefault(NiFiPropertiesLoader.java:130)
        at 
org.apache.nifi.properties.NiFiPropertiesLoader.get(NiFiPropertiesLoader.java:241)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.nifi.NiFi.initializeProperties(NiFi.java:339)
        ... 3 common frames omitted
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to