[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

error in calling Webservice over ssl

Posted on 2010-09-16
2
Medium Priority
?
1,107 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 1500 total points
ID: 33745516
0
 

Author Closing Comment

by:rharivenkatesh
ID: 34314357
Not completed
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

656 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