on 07-28-2014 7:43 PM
When creating a native Android application that uses the MBO Object API, connecting to the SMP server through a Relay Server that's listening for SSL, where/how should the trusted certificate be packaged with the application?
That is, if the stream param value lists "trusted_certificates=mycertificate.crt", Where is the API expecting to find the file, "mycertificate.crt"?
If I'm not mistaken, I believe that under the trusted_certificates parameter you should include the whole path from your project's root folder.
For example, trusted_certificates=/resources/certs/mycertificate.crt
Of course, choose the actual path of the certificate.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That did not work, either, unfortunately.
It just seems to ignore the "trusted_certificates" stream parameter. Through some log spelunking, it seems to always be looking for a certificate file under the app's files directory named "<APP_ID>_trustedCertificates.crt".
Given that, the following code works around the problem:
final AssetManager assets = this.getAssets();
InputStream certFileInputStream = assets.open(CERT_FILE_NAME);
final FileOutputStream certOutputFile = this.openFileOutput(CERT_FILE_NAME, Context.MODE_PRIVATE);
byte[] buffer = new byte[1024];
int len;
while ((len = certFileInputStream.read(buffer)) != -1) {
certOutputFile.write(buffer, 0, len);
}
certOutputFile.flush();
certOutputFile.close();
certFileInputStream.close();
That is, I package the cert under the "assets" folder and then copy it at runtime to the name/location expected by the MBO/MobiLink runtime. This is definitely a "workaround," though. Has no one else come across this problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The communication from the device to the relay server is over https. The communication from the relay server to smp is http.
I followed the instructions at that link, but it still isn't clear where *exactly* the certificate file should go in the application structure. For now, I have it directly under "assets", but that doesn't seem to be working.
On iOS, I put the certificate at the root of the project and included the stream parameter, "trusted_certificates=mycertificate.crt", which worked. The same is not working on Android.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.