Cloud API Log Encrypt Error
CompletedHi I am trying to encrypt the cloud api logs with the jsbridge as described here:
But I am getting the following error:
_setLogEncryptKey JSON Parsed Response: DJIJSResponse(code: 615000, message: java.security.spec.InvalidKeySpecException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: Error parsing public key
main.dart.js:49363 at com.android.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:286)
main.dart.js:49363 at com.android.org.conscrypt.OpenSSLRSAKeyFactory.engineGeneratePublic(OpenSSLRSAKeyFactory.java:57)
main.dart.js:49363 at java.security.KeyFactory.generatePublic(KeyFactory.java:361)
main.dart.js:49363 at com.dji.industry.pilot.platform.log.PLogEncryption.h(PLogEncryption.kt:5)
main.dart.js:49363 at com.dji.industry.pilot.platform.log.PLogFileManager.j(PLogHelper.kt:1)
main.dart.js:49363 at com.dji.industry.pilot.platform.log.PLogHelper.k(PLogHelper.kt:2)
main.dart.js:49363 at com.dji.industry.pilot.platform.log.PLogs.e(PLogs.kt:1)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.PlatformJsMethod.setLogEncryptKey(PlatformJsMethod.kt:2)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.OpenJsMethod$platformSetLogEncryptKey$1.invoke(OpenJsMethod.kt:2)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.OpenJsMethod$platformSetLogEncryptKey$1.invoke(OpenJsMethod.kt:1)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.OpenJsMethod.invokeJsMethod(OpenJsMethod.kt:7)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.OpenJsMethod.invokeJsMethod(OpenJsMethod.kt:1)
main.dart.js:49363 at com.dji.industry.pilot.custom.js.OpenJsMethod.platformSetLogEncryptKey(OpenJsMethod.kt:1)
main.dart.js:49363 at android.os.MessageQueue.nativePollOnce(Native Method)
main.dart.js:49363 at android.os.MessageQueue.next(MessageQueue.java:336)
main.dart.js:49363 at android.os.Looper.loop(Looper.java:174)
main.dart.js:49363 at android.os.HandlerThread.run(HandlerThread.java:67)
main.dart.js:49363 Caused by: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: Error parsing public key
main.dart.js:49363 at com.android.org.conscrypt.NativeCrypto.EVP_parse_public_key(Native Method)
main.dart.js:49363 at com.android.org.conscrypt.OpenSSLKey.getPublicKey(OpenSSLKey.java:284)
I tried with different methods to generate the public key but to of no solution. I used the RSA algorithm to generate the certifacates with 2048 key length as follows:
openssl genrsa -des3 -out private_key.pem 2048
openssl req -new -sha256 -key private_key.pem -out server.csr
openssl req -x509 -sha256 -days 365 -key private_key.pem -in server.csr -out server.pem
1. Are there any other requierements to generate proper certificate for encrypting the logs?
2. Do we have to sign the certificate using a GoDaddy Certificate or Self Signed certificates are okay for log encryption keys?
-
Thanks for the quick response. For me it still does not work.
1. Does the key has to be base64 encoded with utf-8 ?
2. Does the key only contain the actual key without the "-----BEGIN PUBLIC KEY-----" and "-----END PUBLIC KEY-----"?
3. Is the following enough to generate a valid key for encrpytion or do you have maybe some instruction using the openssl tool?
openssl genrsa > pvtkey.key
openssl rsa -in pvtkey.key -pubout -out public.pem4. Do you have a sample android project which does this encryption using the public key for better understanding how it works for the Pilot 2 app?
5. I use only the public key to encrypt the data and try to set it using the jsbridge api. Is this the right way to do it?
Thanks for your support again
-
1. RSA keys are already Base64 encoded upon generation. 2. The key only consists of the actual key data and does not include the "-----BEGIN PUBLIC KEY-----" or "-----END PUBLIC KEY-----" wrappers. 3. It's alright to generate RSA keys using the following commands: openssl genrsa > pvtkey.key openssl rsa -in pvtkey.key -pubout -out public.pem 4. Apologies, but we don't currently have a demo available for this purpose. Also, please note that when encrypting, you should be using the public key, and it should be the public key stripped of newline characters.
Please sign in to leave a comment.
Comments
4 comments