Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Multi-OS Engine: Enabling HTTPS

0.00/5 (No votes)
1 Oct 2015CPOL1 min read 7.7K  
Multi-OS Engine: Enabling HTTPS

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

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.
    mkdir –p ./java/security
  2. Copy the security.properties file from the Android code repository to the directory you created in the previous step.
    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.
    zip –r application.jar ./java
  4. Finally, remove the ./java directory.
    rm –R ./java

Set up CA Certificates

  1. Create the ./android_root/etc/security/cacerts directory.
    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.
    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:

Image 1

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

Image 2

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

Image 3

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)