When using a SSL connection to Mobile Center, ‘It is impossible to create a new session’ error occurs when trying to run a Appium script in Eclipse

  • KM03556048
  • 15-Nov-2019
  • 29-Nov-2019

Summary

Error occurs when using Eclipse to connect to the Appium Server on Mobile Center which is using SSL

Error

When trying to execute an Appium script on a Mobile Center server which is using a SSL connection, the IOSDriver/AndriodDriver will throw the following error:
 
org.openqa.selenium.WebDriverException: It is impossible to create a new session because 'createSession' which takes HttpClient, InputStream and long was not found or it is not accessible
Driver info: driver.version: AndroidDriver
at io.appium. java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:195)
….
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
….

Cause

This error indicates there was an issue connecting to Mobile Center i.e. Eclipse cannot find the required CA Certificate in the loaded jre keystore to allow connection to the Mobile Center server.

Fix

Ensure that the required certificate has been generated to allow access to your Mobile Center server.

More information can be found in the link below:

https://admhelp.microfocus.com/mobilecenter/en/3.1/Content/SSL.htm?Highlight=ss

 

After you have successfully generated the required certificate follow the steps below to locate the trust store that you’re respective JDK is loading:

  1. Create a new Run Configuration in Eclipse
    1. Go to Run > Run Configurations
  2. Inside the arguments tab add the following VM argument:
    1. -Djavax.net.debug=all
  3. On executing the test again, debug information regarding the Java networking will be output
  4. The top of the output should indicate the trust store location
    1. This will confirm the location of the cacerts your JVM is loading
      1. e.g “trustStore is: C:\Program Files\Java\jdk<version>\jre\lib\security\cacerts”

 

***************************CONSOLE OUTPUT*****************************************

Inaccessible trust store: C:\Program Files\Java\jre1.8.0_221\lib\security\jssecacerts

trustStore is: C:\Program Files\Java\jre1.8.0_221\lib\security\cacerts

trustStore type is: jks

trustStore provider is:

the last modified time is: Fri Aug 30 23:17:38 BST 2019

***************************CONSOLE OUTPUT*****************************************

After indicating the required location of the trust store,

  1. Open command prompt as administrator
  2. Type the following commands
    1. Cd C:\Program Files\Java\jdk<version>\jre<Version>\bin
    2. keytool -importcert -trustcacerts -file <Cert file location>\certificate.crt -keystore "<JRE location from above>\lib\security\cacerts" -storepass "changeit"
      1. (this will import the certificate from the specified file location into the keystore cacerts)
  3. Test script in eclipse should now be able to connect to Mobile Center

After completing the steps above, you should now be able to connect to Mobile Center via Appium Server.