Browse Source

Read files for pki certs and idd was modified to add 0x00 at the end of byte array.

Trishia 4 years ago
parent
commit
b133f55169

+ 9 - 1
OnBoardingTool/app/src/main/java/org/iotivity/onboardingtool/FactoryPresetsHandler.java

@@ -9,6 +9,7 @@ import org.iotivity.oc.OcObt;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 
 public class FactoryPresetsHandler implements OCFactoryPresetsHandler {
 
@@ -159,6 +160,13 @@ public class FactoryPresetsHandler implements OCFactoryPresetsHandler {
             Log.e(TAG, "Failed to read " + filepath);
         }
 
-        return ((baos != null) ? baos.toByteArray() : null);
+        if(baos!=null) {
+            int len = baos.toByteArray().length ;
+            byte[] result = Arrays.copyOf(baos.toByteArray(), len + 1);
+            result[len] = (byte)0x00;
+            Log.d(TAG, "bytes length = " + result.length);
+            return result ;
+        }
+        return null ;
     }
 }