title: How to set a certificate to be trusted for a spring RestTemplate
body: <p>I am using Spring RestTemplate in my application to access external web services. This web service hat SSL enabled, however, with a self signed certificate (domain, etc... are also not valid). This is just on a local network, so I do not have to be worry about some security issues. I want to make Spring to accept this certificate. This is what I've done so far:</p>
  
  <p>1.) I have configured my JBOSS 7 to use this keystore</p>
  
  <pre><code>&lt;connector name="https" protocol="HTTP/1.1" socket-binding="https" scheme="https" enable-lookups="false" secure="true"&gt;
      &lt;ssl name="ssl" key-alias="my-private-key" password="rmi+ssl" certificate-key-file="../standalone/configuration/server-keystore.jks" protocol="TLSv1" verify-client="false"/&gt;
  &lt;/connector&gt;
  </code></pre>
  
  <p>2.) Here is the configuration of my RestTemplate Bean (I am using autowireing in my classes)</p>
  
  <pre><code>&lt;bean id="stringHttpConverter" class="org.springframework.http.converter.StringHttpMessageConverter"&gt;&lt;/bean&gt;
  
  &lt;bean id="httpClientParams" class="org.apache.commons.httpclient.params.HttpClientParams"&gt;
      &lt;property name="authenticationPreemptive" value="true"/&gt;
      &lt;property name="connectionManagerClass" value="org.apache.commons.httpclient.MultiThreadedHttpConnectionManager"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="httpClient" class="org.apache.commons.httpclient.HttpClient"&gt;
      &lt;constructor-arg ref="httpClientParams"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="httpClientFactory" class="org.springframework.http.client.CommonsClientHttpRequestFactory"&gt;
      &lt;constructor-arg ref="httpClient"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="restTemplate" class="org.springframework.web.client.RestTemplate"&gt;
      &lt;constructor-arg ref="httpClientFactory"/&gt;
      &lt;property name="messageConverters"&gt;
          &lt;list&gt;
              &lt;!-- &lt;ref bean="marshallingConverter" /&gt; --&gt;
              &lt;ref bean="stringHttpConverter" /&gt;              
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I have imported the server certificate into the keystore, it is definitely in there. What else do I have to do? I've already checked all similar questions here, but none of them helped. Thanks.</p>