移动开发
现在阅读
Multi-OS Engine: Enabling HTTPS
0

Multi-OS Engine: Enabling HTTPS

由 ultracpy2018年1月26日

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:

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

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

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

出处:https://www.codeproject.com/Articles/1034399/Multi-OS-Engine-Enabling-HTTPS

关于作者
ultracpy
评论

你必须 登录 提交评论