Solved

error in calling Webservice over ssl

Posted on 2010-09-16
2
1,043 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
2 Comments
 
LVL 2

Accepted Solution

by:
karthi_bv earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:rharivenkatesh
Comment Utility
Not completed
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Join & Write a Comment

New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now