Multi-OS Engine: Enabling HTTPS

Oct 1, 2015

2 min read

Java

Mobile

Android

macOS

Author picture

by Android on Intel

Contributor

8k Views

0/ 5

Intel® Developer Zone offers tools and how-to information for cross-platform app development, platform and technology information, code samples, and peer expertise to help developers innovate and succeed. Join our communities for Android, Internet of Things, Intel® RealSense™ Technology, and Windows to download tools, access dev kits, share ideas with like-minded developers, and participate in hackathon’s, contests, roadshows, and local events.

The standard java.net.URL class provides HTTPS functionality. To make it work you only need to set up security providers and CA certificates (cacerts).

Here is how you can do this on Mac OS X* from the command line.

Change the current directory to the resources directory of your Multi-OS Engine module and do the following:

Set up Security Providers

  1. Create a ./java/security directory.
    CODE
    mkdir –p ./java/security
  2. Copy the security.properties file from the Android code repository to the directory you created in the previous step.
    CODE
    cd ./java/security/
    
    curl –o ./security.tar.gz "https://android.googlesource.com/platform/libcore/+archive/master/luni/src/main/java/java/security.tar.gz"
    
    tar --extract --file=./security.tar.gz ./security.properties
    
    rm ./security.tar.gz
    
    cd ../../
  3. Zip the ./java directory to an application.jar file.
    CODE
    zip –r application.jar ./java
  4. Finally, remove the ./java directory.
    CODE
    rm –R ./java

Set up CA Certificates

  1. Create the ./android_root/etc/security/cacerts directory.
    CODE
    mkdir –p ./ android_root/etc/security/cacerts
  2. Copy the cacerts directory from the Android code repository to the directory you created in the previous step.
    CODE
    cd ./android_root/etc/security/cacerts
    curl –o ./cacerts.tar.gz "https://android.googlesource.com/platform/libcore/+archive/master/luni/src/main/files/cacerts.tar.gz"
    tar --extract --file=./cacerts.tar.gz
    rm ./cacerts.tar.gz
    cd ../../../../

In the Finder application the resulting directory structure of your Intel INDE Module should look as follows:

Article image

In Android Studio the structure of your Multi-OS Engine module should look as follows:

Article image

The structure of the resulting Xcode* project should look as follows:

Article image

Now you should be able to use HTTPS in your project through the java.net.URL class.

Samples

As from Multi-OS Engine build 307, you can find the RssReader example in the samples folder that shows how to use HTTP and HTTPS. On a Mac, the samples folder will typically be located in the multi-os Engine installation folder: /Applications/Intel/INDE/multi_os_engine/samples. On Windows, the folder will typically be: C:\Intel\INDE\multi_os_engine_<build_number>/samples

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)