I have an application jar from which I m calling an HTTPS url using DefaultHTTPClient class object but its giving peer not authenticate exception, so I want to sign jar using keystore.
I have .cer file which has public key and I can able to import into keystore but when I use jarsigner tool it says certificate chain not found.you must have private key and associate public key.
I have .pfx file also which is suppose to an private key but I don't know how to import it.can any one able to tell me the steps how to import .pfx file and use in jarsigner.
Correct me if I m wrong somewhere..
UPDATE
As per @Duncan I am able to import .cer file in JVM by referring This Link.. I used bellowed command to import .cer into cacerts
c:\Program Files\Java\jre7\bin>keytool -importcert -alias esbcert -file "e:\Desktop\esbcert\esb.cer" -keystore "c:\Program Files\Java\jre7\lib\security\cacerts"
-storepass changeit
After this I entered 'y' to trust the certificate
Trust this certificate? [no]: y
Certificate was added to keystore
After that I Run my application but it still gives me javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
Stack is as follows :
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.jav
a:126)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFact
ory.java:572)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnect
ion(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedCli
entConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(Default
RequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultReq
uestDirector.java:480)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
ient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
ient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
ient.java:784)
at testhttps.TestHTTPS.testWithMKCLHTTPClient(TestHTTPS.java:95)
at testhttps.TestHTTPS.main(TestHTTPS.java:49)
My Code is :
String url = "https://domain.org/webapp/transformer/doTransformer/doReg";
try {
HttpPost postRequest = new HttpPost(url);
HttpResponse httpResponse = null;
DefaultHttpClient httpClient = new DefaultHttpClient();
httpResponse = httpClient.execute(postRequest);
} catch (Exception e) {
e.printStackTrace();
}