0 Replies Latest reply on Mar 7, 2005 3:19 AM by Yoge

    Access JNDI over HTTPS & http-invoker.sar

    Yoge Newbie

      I tried to connect to JBoss MBeanServer through http-invoker.sar

      I followed the steps given in http://docs.jboss.org/jbossas/admindevel326/html/ch3.chapter.html#d0e7813

      Below code gets JNDI reference
      String host = "yogendrav";
      int port = 8443;
      Properties jndiprops = new Properties();
      String servletUrl="/invoker/JNDIFactory";
      String providerurl="https://"+host+":"+port+servletUrl;
      InitialContext ic = new InitialContext(jndiprops);
      Object o =ic.lookup("jmx/rmi/RMIAdaptor");

      But the code works only if add the keystore file in the system property

      If I dont add the below line I get certification handshake exception.
      System.setProperty("javax.net.ssl.trustStore", "E:\\jboss\\jboss-3.2.6\\jboss-3.2.6\\server\\default\\conf\\chap8.keystore");

      I want to avoid adding the keystore file in the code.

      I tried below code snippet to override default TrustManager with mine which dont bother about trusting the server certificates.

      TrustManager[] trustAllCerts = new TrustManager[]{
      new X509TrustManager() {
      public java.security.cert.X509Certificate[] getAcceptedIssuers() {
      return null;
      public boolean isClientTrusted(
      java.security.cert.X509Certificate[] certs) {
      return true;
      public boolean isServerTrusted(
      java.security.cert.X509Certificate[] certs) {
      return true;
      try {
      SSLContext sc = SSLContext.getInstance("SSLv3");
      sc.init(null, trustAllCerts, null);//new java.security.SecureRandom());

      } catch (Exception e) {

      Unfortunately this workaround doesnot work!!!!!!!!

      My question is how to override default trust manager so that I dont have to bother about adding keystore file in the program.

      Additional info:
      1, Iam new to SSL
      2, I dont mind accepting any certificates in my java client.

      Thanks a lot in advance for helping me.