How to migrate/update ssl connectivity from Apache httpClient 4.2.6 to httpClient 4.5.14 in bean xml

81 views Asked by At

We are migrating from Apache httpClient 4.2.6 to Apache httpClient 4.5.14. We are creating beans using bean xml in Spring boot application. Many classes and methods are deprecated in httpClient 4.5.14 version. In below snippet Scheme, SSLSocketFactory and SchemeRegistryFactory are deprecated.


   <beans>
      <bean id="RAM.SSLSocketFactoryBean" class="org.apache.http.conn.ssl.SSLSocketFactory">
         <property name="enabledSSLProtocols" value="${RAM.enabledSSLProtocols}" />
         <property name="trustStoreLocation" value="${csi.adapter.projecthomepath}/${RAM.truststorelocation}" />
         <property name="trustStorePassword" value="${RAM.truststore.password}" />
         <property name="publicKeyAliasList" value="${RAM.publickey.alias.list}" />
         <property name="enabledCiphers" value="${RAM.enabledCiphers}" />
      </bean>
      <bean id="RAM.Scheme" class="org.apache.http.conn.scheme.Scheme">
         <constructor-arg index="0" value="https" />
         <constructor-arg index="1" value="443" />
         <constructor-arg index="2" ref="RAM.SSLSocketFactoryBean" />
      </bean>
      <bean id="RAM.SchemeRegistry" class="org.springframework.beansfactory.config.MethodInvokingFactoryBean">
         <property name="targetClass">
            <value>org.apache.http.impl.conn.SchemeRegistryFactory</value>
         </property>
         <property name="targetMethod">
            <value>createDefault</value>
         </property>
      </bean>
      <bean class="erg.springframework.beans.factory.config.MethodInvokingFactoryBean" lazy-init="false">
         <property name="targetObject">
            <ref bean="RAM.SchemeRegistry" />
         </property>
         <property name="targetMethod">
            <value>register</value>
         </property>
         <property name="arguments">
            <list>
               <ref bean="RAM.Scheme" />
            </list>
         </property>
      </bean>
   </beans>

My requirement is to update above XML by using httpClient 4.5.14 version and establish SSL connection. Please help me.

0

There are 0 answers