Solved

error in calling Webservice over ssl

Posted on 2010-09-16
2
1,060 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
ID: 33745516
0
 

Author Closing Comment

by:rharivenkatesh
ID: 34314357
Not completed
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Spring Controller - inheritance in request parameter 3 60
wordlen challenge 3 66
HashMap Vs TreeMap 12 60
HSSFWorkbook cannot be resolved error 10 68
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…
These instructions are based on installing Owncloud on your new raspberry pi connected with a usb HDD. What do you need Part A? A Raspberry Pi, model B. A boot SD card for the Raspberry Pi. A usb HDD An Ethernet cable to connect to the lo…
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.

785 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