I need to connect to a REST based web service.
( https://someurl.com/api/lookup/jobfunction/lang/EN )
In IE or Chrome browser, when I try to access this URL, I get a certificate that I have to trust and accept it to continue. After that I have to enter a username and password, and then get a JSON response.
The same thing I have to do this programmatically for an Android application.
Tried with custom EasySSLSocketFactory and EasyX509TrustManager, did not work. I got the following error: java.security.cert.CertPathValidatorException: The chain anchor for the certification path was not found.
The BKS keystore is used, please note that mykeystore.bks is an empty file before I executed the commands below.
keytool -importcert -v -trustcacerts -file "test.crt" -alias IntermediateCA -keystore "mykeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk15on-148.jar" -storetype BKS -storepass abcd1234 keytool -list -keystore "mykeystore.bks" -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath "bcprov-jdk15on-148.jar" -storetype BKS -storepass abcd1234
MyHTTPClient.java is as follows:
public class MyHttpClient extends DefaultHttpClient { final Context context; public MyHttpClient(Context context) { this.context = context; } @Override protected ClientConnectionManager createClientConnectionManager() { SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
When I call webservice, I get the following error: Called: java.lang.AssertionError: java.io.IOException: wrong keystore version
Please tell me what I need to do to connect to an HTTPS-based web service that has user credentials and a password. ......
user2290834
source share