Results 1 to 7 of 7
- 10-03-2011, 09:26 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 5
- Rep Power
- 0
- 10-03-2011, 03:31 PM #2
Member
- Join Date
- Jun 2008
- Posts
- 43
- Rep Power
- 0
Re: How to use .cer file inside Java Code
What do you want to do with it? Normally when I've worked with certificates in the past I just loaded them into a keystore\truststore and then referenced that in java. I think there is also a java keystore somewhere within the installation directories of Java.
If you could provide a little more information it might make it easier to help you.
- 10-03-2011, 03:49 PM #3
Member
- Join Date
- Sep 2011
- Posts
- 14
- Rep Power
- 0
Re: How to use .cer file inside Java Code
I used .cer file to put a Digital certificate on my pdf file.
I created .cer file by using cmd.
- 10-05-2011, 07:37 AM #4
Member
- Join Date
- Jan 2010
- Location
- Lahore
- Posts
- 5
- Rep Power
- 0
Re: How to use .cer file inside Java Code
you can use the followng commad to convert .cer file to keystore
1.keytool -import -keystore client.keystore -file WSS.cer
2.Input password for your output file(say abc)
This will create a file named client.keystore
Then you can use it in your java code.
System.setProperty("javax.net.ssl.trustStore", "client.keystore");
System.setProperty("javax.net.ssl.trustStorePasswo rd","abc");
- 10-06-2011, 11:42 AM #5
Member
- Join Date
- Oct 2011
- Posts
- 5
- Rep Power
- 0
Re: How to use .cer file inside Java Code
There is a web service built in .Net and running on SSL. I am using axis client to connect to it. First I used a .jks certificate to connect to it. But now I have to use .cer file to connect. I need to be able to connect to the web service. I have used keytool for keystore generation but I am not able to connect to web service.
I use
keytool -import -keystore client.keystore -file WSS.cer
to generate the keystore and use it in the code using
System.setProperty("javax.net.ssl.keyStore", keystorePath);
System.setProperty("javax.net.ssl.keyStorePassword ", password);
System.setProperty("javax.net.ssl.trustStore", keystorePath);
System.setProperty("javax.net.ssl.trustStorePasswo rd", password);
But I am not able to connect to it.
Can someone please guide me how to connect to it.
- 10-06-2011, 12:42 PM #6
Member
- Join Date
- Jan 2010
- Location
- Lahore
- Posts
- 5
- Rep Power
- 0
Re: How to use .cer file inside Java Code
what does it means??
"But I am not able to connect to it"
What message/Exception you are getting?
and you only need to set the following
System.setProperty("javax.net.ssl.trustStore", keystorePath);
System.setProperty("javax.net.ssl.trustStorePasswo rd", password);
Don't use
System.setProperty("javax.net.ssl.keyStore", keystorePath);
System.setProperty("javax.net.ssl.keyStorePassword ", password);
- 10-06-2011, 01:21 PM #7
Member
- Join Date
- Oct 2011
- Posts
- 5
- Rep Power
- 0
Re: How to use .cer file inside Java Code
I have tried using it but I am getting the following exception
org.apache.axis2.AxisFault: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at org.apache.axis2.AxisFault.makeFault(AxisFault.jav a:430)
at org.apache.axis2.transport.http.AxisRequestEntity. writeRequest(AxisRequestEntity.java:98)
at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.writeRequestBody(EntityEnclosingMethod.j ava:499)
at org.apache.commons.httpclient.HttpMethodBase.write Request(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execu te(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteWithRetry(HttpMethodDirector.java:398)[INFO] Unable to sendViaPost to url[https://csr.pmex.com.pk/ncel.webserv...radedata.asmx]
org.apache.axis2.AxisFault: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at org.apache.axis2.AxisFault.makeFault(AxisFault.jav a:430)
at org.apache.axis2.transport.http.AxisRequestEntity. writeRequest(AxisRequestEntity.java:98)
at org.apache.commons.httpclient.methods.EntityEnclos ingMethod.writeRequestBody(EntityEnclosingMethod.j ava:499)
at org.apache.commons.httpclient.HttpMethodBase.write Request(HttpMethodBase.java:2114)
at org.apache.commons.httpclient.HttpMethodBase.execu te(HttpMethodBase.java:1096)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteWithRetry(HttpMethodDirector.java:398)
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender .executeMethod(AbstractHTTPSender.java:560)
at org.apache.axis2.transport.http.HTTPSender.sendVia Post(HTTPSender.java:199)
at org.apache.axis2.transport.http.HTTPSender.send(HT TPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTranspo rtSender.writeMessageWithCommons(CommonsHTTPTransp ortSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTranspo rtSender.invoke(CommonsHTTPTransportSender.java:22 5)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine .java:438)
at org.apache.axis2.description.OutInAxisOperationCli ent.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationCli ent.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(Op erationClient.java:165)
at org.tempuri.WSTradeDataStub.getFxRates(WSTradeData Stub.java:2151)
at Driver2.main(Driver2.java:179)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1611)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRe cord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write (AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
at org.apache.axis2.transport.http.AxisRequestEntity. writeRequest(AxisRequestEntity.java:94)
... 18 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:285)
at sun.security.validator.PKIXValidator.engineValidat e(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validato r.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:1014)
... 28 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder. engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathB uilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:280)
... 34 more
at org.apache.commons.httpclient.HttpMethodDirector.e xecuteMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMe thod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender .executeMethod(AbstractHTTPSender.java:560)
at org.apache.axis2.transport.http.HTTPSender.sendVia Post(HTTPSender.java:199)
at org.apache.axis2.transport.http.HTTPSender.send(HT TPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTranspo rtSender.writeMessageWithCommons(CommonsHTTPTransp ortSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTranspo rtSender.invoke(CommonsHTTPTransportSender.java:22 5)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine .java:438)
at org.apache.axis2.description.OutInAxisOperationCli ent.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationCli ent.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(Op erationClient.java:165)
at org.tempuri.WSTradeDataStub.getFxRates(WSTradeData Stub.java:2151)
at Driver2.main(Driver2.java:179)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1611)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:187)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:181)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:1035)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:124)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:516)
at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:454)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:884)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1112)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRe cord(SSLSocketImpl.java:623)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write (AppOutputStream.java:59)
at java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
at org.apache.axis2.transport.http.AxisRequestEntity. writeRequest(AxisRequestEntity.java:94)
... 18 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:285)
at sun.security.validator.PKIXValidator.engineValidat e(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validato r.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:1014)
... 28 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder. engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathB uilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:280)
... 34 more
Similar Threads
-
Need help creating new instances dynamically. Compilable code inside.
By cedron in forum New To JavaReplies: 6Last Post: 09-12-2011, 02:27 PM -
using java code inside javascipt-- in jsp
By happy in forum Java ServletReplies: 6Last Post: 06-15-2011, 05:58 PM -
ArrayLists do not print to the terminal window, why? long code inside
By caps_lock in forum New To JavaReplies: 5Last Post: 05-25-2009, 09:03 PM -
search file inside Zip, Rar file
By hungerToJava in forum New To JavaReplies: 0Last Post: 03-21-2009, 08:36 AM -
Running .java-files won't work/compile does!(Code inside)
By wyldstyle in forum New To JavaReplies: 6Last Post: 02-06-2009, 08:05 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks