Hi,
I have posted the same question 2 month ago here and lot of nice people helped me. I was able to go through all the instructions mentioned in the link below to set up the ssl connections.Below are the links:
Configure connections to the data source to use SSL. (link1)
Configure your Java Runtime Environment to use SSL. (link2)
In the link2, I got confused at step #5 where I have to tell java to user the trust store at runtime since I dont have any Java Class Name to specify in the Web but anyway Below is my code, if you know what is wrong please do let me know"
applicationContext.xml:
<bean id="dataSource" class="com.mycomp.spring.datasource.ExtendedBasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.informix.jdbc.IfxDriver" />
<property name="url"
value="jdbc:informix-sqli://host_name:port/DBName:INFORMIXSERVER=ServerName;DELIMIDENT=y;" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="minIdle" value="2" />
<property name="connectionProperties">
<props>
<prop key="sslConnection">true</prop>
</props>
</property>
</bean>
com.mycomp.spring.datasource.ExtendedBasicDataSource
public class ExtendedBasicDataSource extends BasicDataSource {
private static final Log logger = LogFactory
.getLog(ExtendedBasicDataSource.class);
public void setConnectionProperties(Properties props) {
for (Iterator iter = props.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
logger
.info("##################################################################################");
logger.info("Setting the value for the key: "
+ (String) entry.getKey() + " value: "
+ (String) entry.getValue());
logger
.info("##################################################################################");
addConnectionProperty((String) entry.getKey(), (String) entry
.getValue());
}
}
}
Below is the error log which I am getting using the JBOSS Server:
JBoss Bootstrap Environment
JBOSS_HOME: /opt/imp/jboss/Jboss5
JAVA: /opt/java6/bin/java
JAVA_OPTS: -Dprogram.name=run.sh -server -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djavax.net.ssl.trustStore=/www/public/comp/cacerts
CLASSPATH: /opt/imp/jboss/Jboss5/bin/run.jar:/opt/java6/lib/tools.jar
=========================================================================
20:03:39,915 INFO [ContextLoader] Root WebApplicationContext: initialization started
20:03:39,956 INFO [XmlWebApplicationContext] Refreshing org.springframework.web.context.support.XmlWebApplicationContext@119ceb1: display name [Root WebApplicationContext]; startup date [Wed Jun 23 20:03:39 EDT 2010]; root of context hierarchy
20:03:40,025 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
20:03:40,156 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/brokerRegistration_applicationContext.xml]
20:03:40,191 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/quickQuote_applicationContext.xml]
20:03:40,227 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/customerApplication_applicationContext.xml]
20:03:40,312 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/eSign_applicationContext.xml]
20:03:40,340 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/others_applicationContext.xml]
20:03:41,061 INFO [ExtendedBasicDataSource] ##################################################################################
20:03:41,061 INFO [ExtendedBasicDataSource] Setting the value for the key: sslConnection value: true
20:03:41,061 INFO [ExtendedBasicDataSource] ##################################################################################
20:03:41,150 INFO [LocalContainerEntityManagerFactoryBean] Building JPA container EntityManagerFactory for persistence unit 'mycompPU'
20:03:41,185 INFO [Version] Hibernate Annotations 3.3.0.GA
20:03:41,200 INFO [Environment] Hibernate 3.2.5
20:03:41,205 INFO [Environment] hibernate.properties not found
20:03:41,207 INFO [Environment] Bytecode provider name : javassist
20:03:41,211 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
20:03:41,284 INFO [Version] Hibernate EntityManager 3.3.1.GA
20:03:41,396 INFO [AnnotationBinder] Binding entity from annotated class: com.mycomp.breg.entity.M735broker
20:03:41,456 INFO [EntityBinder] Bind entity com.mycomp.breg.entity.M735broker on table m735broker
20:03:41,511 INFO [AnnotationBinder] Binding entity from annotated class: com.mycomp.breg.entity.M740pkmast
20:03:41,513 INFO [QueryBinder] Binding named native query: packageList => {call get_QQPackages(?)}
20:03:41,513 INFO [EntityBinder] Bind entity com.mycomp.breg.entity.M740pkmast on table m740pkmast
20:03:41,525 INFO [AnnotationBinder] Binding entity from annotated class: com.mycomp.breg.entity.M755iprem
20:03:41,525 INFO [EntityBinder] Bind entity com.mycomp.breg.entity.M755iprem on table m755iprem
20:03:41,541 INFO [ResultsetMappingSecondPass] Binding resultset mapping: packages
20:03:41,551 INFO [Version] Hibernate Validator 3.0.0.GA
20:03:41,820 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
20:03:41,826 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
20:03:42,429 WARN [SettingsFactory] Could not obtain connection metadata
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Message text will be provided in later releases java.lang.IndexOutOfBoundsException)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:47)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.sql.SQLException: Message text will be provided in later releases java.lang.IndexOutOfBoundsException
at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:483)
at com.informix.jdbc.IfxSqliConnect.<init>(IfxSqliConnect.java:1330)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
... 86 more
Caused by: java.lang.IndexOutOfBoundsException
at java.io.BufferedInputStream.read(BufferedInputStream.java:310)
at com.informix.asf.IfxDataInputStream.read(IfxDataInputStream.java:127)
at com.informix.asf.Connection.recvConnectionResponse(Connection.java:559)
at com.informix.asf.Connection.establishConnection(Connection.java:1545)
:42,466 INFO [SettingsFactory] Scrollable result sets: disabled
20:03:42,466 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
20:03:42,466 INFO [SettingsFactory] Connection release mode: auto
If you see in the logs I am passing the java runtime variable mentioned at step #5 in link2:
-Djavax.net.ssl.trustStore=/www/public/comp/cacerts
for the keystore and also logger is telling me that I was able to set the sslConnection variable to true.
I have tried everything I knew if you have some suggestions please do let me know. I will really appreciate any kind of help in this regard.
Thanks in advance!