[jboss-user] [Installation, Configuration & Deployment] - Re: Trusted certificate stores used by Jboss 4.2.2 Applicati

navkalp do-not-reply at jboss.com
Thu Sep 3 02:45:54 EDT 2009


I fixed this issue, I am putting the solution I tried to find,

I created one JSP, and saw which trusted certificate store is being used. My JSP gave me the answer, I added the root certificate in the trusted keystore shown by my jsp,, and it started working:)


<%@page import="java.net.*,java.io.*,com.sun.net.ssl.*,com.sun.net.ssl.internal.ssl.Provider,java.security.*,javax.net.ssl.*,java.util.*"%>
<%
 String ls_resp = null;




        try {

			String surl = "https://www.samba.com/b2b/epayments/sc/SCConnectRequest.svl";
			String ls_psswd = "Ol2882666";
			String ls_cert_path = "/App1/web/install/samba/certificate/GODigitalID.pfx";

			BufferedReader lo_bufferedReader = null;
            		BufferedInputStream lo_bis       = null;
			com.sun.net.ssl.SSLContext ctx   = null;
			com.sun.net.ssl.KeyManagerFactory kmf = null;
			KeyStore ks                      = null;
			java.net.URL uRL                 = null;

	        	uRL= new java.net.URL(null,new String(surl),new com.sun.net.ssl.internal.www.protocol.https.Handler());
			ctx = com.sun.net.ssl.SSLContext.getInstance("SSL");
			kmf = com.sun.net.ssl.KeyManagerFactory.getInstance("SunX509");
			ks  = KeyStore.getInstance("PKCS12");
		
			char[] lc_psswd = ls_psswd.toCharArray();
			ks.load(new FileInputStream(ls_cert_path), lc_psswd);
			kmf.init(ks, lc_psswd);
			ctx.init(kmf.getKeyManagers(), null, null);
			SSLSocketFactory sslSocketFactory = ctx.getSocketFactory();
            	Enumeration aliases = ks.aliases();
			while (aliases.hasMoreElements())
			{
				out.println(aliases.nextElement());
			}
           out.println("here 1");

			com.sun.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
		    com.sun.net.ssl.HttpsURLConnection httpsURLConnection = (com.sun.net.ssl.HttpsURLConnection)uRL.openConnection();
		    httpsURLConnection.setHostnameVerifier(httpsURLConnection.getDefaultHostnameVerifier());
                    out.println(System.getProperty("javax.net.ssl.trustStore"));
                    System.setProperty("javax.net.ssl.trustStore", "/usr/java/jre/lib/security/cacerts");
                    System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
		      out.println("here 2");
                    out.println(System.getProperty("javax.net.ssl.trustStore"));
            	    httpsURLConnection.setDoOutput(true);
                    httpsURLConnection.setDoInput(true);
                    httpsURLConnection.setRequestMethod("POST");
		    httpsURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
	            OutputStream lo_out = httpsURLConnection.getOutputStream();
	             out.println("here 3");
		    //lo_out.write(qstring, 0, qstring.length);
            	    lo_out.flush();
            	    int c;

		    lo_bis = new BufferedInputStream(httpsURLConnection.getInputStream());
        	    StringBuffer lo_tmp = new StringBuffer();
        	      out.println("here 4");
			while((c = lo_bis.read())!= -1) {
				lo_tmp.append((char)c);
			}
			lo_bis.close();
			lo_out.close();
			ls_resp = lo_tmp.toString();
			out.println("ls_resp"+ls_resp);



		} catch(Exception e) {
			
			out.println(e.toString());

        }
%>


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4253215#4253215

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4253215



More information about the jboss-user mailing list