Run your PaaS application locally while calling Oracle SaaS secure RESTful APIs

Amr Gawish
kblog
Published in
3 min readJun 17, 2016

--

When you try run your ADF PaaS application locally, while you are using Oracle SaaS RESTful APIs, you can get an error like this one

This can be frustrating and can persuade developers to always deploy to JCSSX directly and testing their code there, this cycle can take too long and can dramatically increase development time.

The same thing happens if you are trying to test your calls to the RESTful APIs through Java, without running weblogic, which can also be frustrating at times.

The Idea

Web Applications

In order to be able to run your web application (ADF) locally you need to make sure that Oracle Cloud certificate exists in your local weblogic certificate keystore, luckily you can change that from JDeveloper preferences.

The other thing is that you might need to switch your SSL SocketFactory provider from the default Weblogic Provider to Sun’s Provider, this is not a problem in Desktop applications since it uses the JDK default one which is Sun SocketFactory.

Desktop Applications

If you are running your REST calls from a Desktop Java Application, you will need to include the Keystore as a Java Option as part of your running command, which also can be done by JDeveloper.

The implementation

First thing is to download the Oracle Cloud certificate from your browser or command line.

Also make sure you install the latest Java 8 JDK from here.

Open your command line and type the following command:

keytool -importcert -alias oracleCloud -file <PATH_TO_ORACLE_CLOUD_SERVICE_CER_FILE> -keystore <YOUR_JAVA_8_DIRECTORY>\jre\lib\security\cacerts

Note: If you are prompted for password enter the password “changeit” without the quotes

After that you want to open your JDeveloper Preferences, Credentials settings and put the following path into Client Trusted Certificate Keystore, also make sure you remove the password.

<YOUR_JAVA_8_DIRECTORY>\jre\lib\security\cacerts

Note: If you installed Java 8 inside Program Files directory, you might need to replace the string “Program Files” with “Progra~1”

By adding this in preferences, it’ll be passed to Weblogic when you start it as the following Java Option

-Djavax.net.ssl.trustStore=<YOUR_JDK8_CA_PATH>

After that you need to do two things in order for your project to work on Desktop and Web application level.

Desktop Application

Open your desktop Application Project properties (It can also be your Model project of your ADF application), from the Left Hand Side menu select Run / Debug / Profile and press Edit.

Add the below in the Java Options field

-Djavax.net.ssl.trustStore=<YOUR_JDK8_CA_PATH>

Web Application

Open your web Application Project properties (ViewController project equivalent), from the Left Hand Side menu select Run / Debug / Profile and press Edit.

Add the below in the Java Options field

-DUseSunHttpHandler=true -Dssl.SocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl -Dssl.ServerSocketFactory.provider=sun.security.ssl.SSLSocketFactoryImpl

The above Java Options set the default SSL Provider to Sun’s implementation instead of Weblogic’s.

After that you should be able to run your application locally without any problems.

--

--

Editor for

A father, Gamification advocate, and a fellow software craftsman!