Using certificates within Fuse
rogelio_sevilla1 Sep 5, 2011 1:10 PMGood day everyone:
I'm currently developing an application that makes use of ssl certificates to extract information from a https website. I tested the app as a stand alone and everything works as it should. My code look like this:
URL ur = new URL("my https url");
System.setProperty("javax.net.ssl.trustStore", "config/myKeyStoreFile")
URLConnection conn = ur.openConnection();
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
String outStr=templateProcessorHelper.getRequestTemplate(runtimeValue);
logger.info("Sending POST Request:\n"+outStr);
Note: I created the config/myKeyStoreFile file into my Fuse installation folder
However, when deploying the same application into the ESB, the command conn.getOutputStream() (which is on the fourth line), throws this exception:
Exception occurred in target VM: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:179)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:186)
at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:362)
at sun.net.NetworkClient.doConnect(NetworkClient.java:145)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
at sun.net.www.protocol.https.HttpsClient.(HttpsURLConnectionImpl.java:65)
at sun.net.www.protocol.https.Handler.openConnection(Handler.java:42)
at sun.net.www.protocol.https.Handler.openConnection(Handler.java:37)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.felix.framework.URLHandlersStreamHandlerProxy.openConnection(URLHandlersStreamHandlerProxy.java:303)
at java.net.URL.openConnection(URL.java:945)
at mycompany.feed.processor.loaders.URLLoaderHelper.loadData(URLLoaderHelper.java:63)
... 37 more
Caused by: java.security.cert.CertificateException: Unable to initialize, java.io.IOException: DerInputStream.getLength(): lengthTag=6, too big.
at sun.security.x509.X509CertImpl.(X509CertImpl.java:179)
... 68 more
I thought it could be a problem with my certificate, however, i'm using the same jdk version in the stand alone app and on the feature I deployed on fuse but only the latter gives me this problem. I wonder if there's any special process to correctly deploy a certificate into a bundle within fuse or am i mising something else in here??.
Thanks a lot in advance :-D