Solved

error in calling Webservice over ssl

Posted on 2010-09-16
2
1,075 Views
Last Modified: 2012-05-10
Hi,

While running the webservice client (RPC), I am getting the following error....

[9/16/10 15:04:08:979 EDT] 0000003e SystemErr     R Caused by: com.ibm.wsspi.channel.framework.exception.ChannelException: com.ibm.wsspi.channel.framework.exception.ChannelException: Invalid trust file name of null
[9/16/10 15:04:08:979 EDT] 0000003e SystemErr     R       at com.ibm.ws.ssl.channel.impl.SSLChannel.createSSLContext(SSLChannel.java:451)
[9/16/10 15:04:08:979 EDT] 0000003e SystemErr     R       at com.ibm.ws.ssl.channel.impl.SSLChannel.delayedInit(SSLChannel.java:241)
[9/16/10 15:04:08:979 EDT] 0000003e SystemErr     R       at com.ibm.ws.ssl.channel.impl.SSLChannel.init(SSLChannel.java:190)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.ssl.channel.impl.WSSSLChannel.init(WSSSLChannel.java:153)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.ChannelFrameworkImpl.initChannelInChain(ChannelFrameworkImpl.java:1190)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.ChannelFrameworkImpl.initChainInternal(ChannelFrameworkImpl.java:2387)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.OutboundVirtualConnectionFactoryImpl.<init>(OutboundVirtualConnectionFactoryImpl.java:81)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.WSVirtualConnectionFactoryImpl.<init>(WSVirtualConnectionFactoryImpl.java:29)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.WSChannelFrameworkImpl.createVirtualConnectionFactory(WSChannelFrameworkImpl.java:1181)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.channel.framework.impl.ChannelFrameworkImpl.getOutboundVCFactory(ChannelFrameworkImpl.java:511)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.runtime.component.ChannelFrameworkServiceImpl.getOutboundVCFactory(ChannelFrameworkServiceImpl.java:426)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       at com.ibm.ws.webservices.engine.transport.channel.WSChannelManager.getVCFactory(WSChannelManager.java:889)
[9/16/10 15:04:08:994 EDT] 0000003e SystemErr     R       ... 49 more



I configured the keystore, Truststore and server certificate. keystore.jsk,truststore.jsk place inside the Jar. the client code as follows...


protected SSLSocketFactory getSSLSocketFactory()
    throws IOException, GeneralSecurityException
  {
            Security.addProvider(new com.ibm.jsse2.IBMJSSEProvider2());
           
            TrustManager[] tms=getTrustManagers();

    // Call getKeyManagers to get suitable key managers
    KeyManager[] kms=getKeyManagers();

    // Now construct a SSLContext using these KeyManagers. We
    // specify a null TrustManager and SecureRandom, indicating that the
    // defaults should be used.
    SSLContext context=SSLContext.getInstance("SSL");
    context.init(kms, tms, null);


    // Finally, we get a SocketFactory, and pass it to SimpleSSLClient.
    SSLSocketFactory ssf=context.getSocketFactory();
    HttpsURLConnection.setDefaultSSLSocketFactory(ssf);
    return ssf;
  }

     
      /**
       * Returns an array of TrustManagers, set up to use the required
         * trustStore. This is pulled out separately so that later  
         * examples can call it.
         * This method does the bulk of the work of setting up the custom
         * trust managers.
         * @param trustStore the TrustStore to use. This should be in JKS format.
         * @param password the password for this TrustStore.
         * @return an array of TrustManagers set up accordingly.
         */
        protected TrustManager[] getTrustManagers()
          throws IOException, GeneralSecurityException
        {
          // First, get the default TrustManagerFactory.
         // String alg=TrustManagerFactory.getDefaultAlgorithm();
          TrustManagerFactory tmFact=TrustManagerFactory.getInstance("IbmX509","IBMJSSE2");
         
          // Next, set up the TrustStore to use. We need to load the file into
          // a KeyStore instance.
          FileInputStream fis=new FileInputStream(Thread.currentThread().getContextClassLoader().getResource("TrustFile.jks").getFile());
          KeyStore ks=KeyStore.getInstance("jks");
          ks.load(fis, "XXXX".toCharArray());
          fis.close();

          // Now we initialise the TrustManagerFactory with this KeyStore
          tmFact.init(ks);

          // And now get the TrustManagers
          TrustManager[] tms=tmFact.getTrustManagers();
          return tms;
        }

     
  /**
   * Returns an array of KeyManagers, set up to use the required
   * keyStore. This is pulled out separately so that later  
   * examples can call it.
   * This method does the bulk of the work of setting up the custom
   * trust managers.
   * @param trustStore the KeyStore to use. This should be in JKS format.
   * @param password the password for this KeyStore.
   * @return an array of KeyManagers set up accordingly.
   */
  protected KeyManager[] getKeyManagers()
    throws IOException, GeneralSecurityException
  {
    // First, get the default KeyManagerFactory.
    String alg=KeyManagerFactory.getDefaultAlgorithm();
    KeyManagerFactory kmFact=KeyManagerFactory.getInstance("IbmX509","IBMJSSE2");
   
    // Next, set up the KeyStore to use. We need to load the file into
    // a KeyStore instance.
    FileInputStream fis=new FileInputStream(Thread.currentThread().getContextClassLoader().getResource(tKeyFile.jks").getFile());
    KeyStore ks=KeyStore.getInstance("jks");
    ks.load(fis, "XXXXx".toCharArray());
    fis.close();

    // Now we initialise the KeyManagerFactory with this KeyStore
    kmFact.init(ks, "XXXXx".toCharArray());

    // And now get the KeyManagers
    KeyManager[] kms=kmFact.getKeyManagers();
    return kms;
  }
0
Comment
Question by:rharivenkatesh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
karthi_bv earned 500 total points
ID: 33745516
0
 

Author Closing Comment

by:rharivenkatesh
ID: 34314357
Not completed
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc. Solution : Return a XML Document instea…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question