[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1123
  • Last Modified:

error in calling Webservice over ssl

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
rharivenkatesh
Asked:
rharivenkatesh
1 Solution
 
rharivenkateshAuthor Commented:
Not completed
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now