title: How support multiple TrustStores in java SSL client application
body: <p>In our java application we need to communicate with a list of servers on SSL using https protocol. The list of servers to communicate will change at runtime. Initially we do not have any of the server's certificate. At runtime, we will obtain a new server's certificate and add the public key certificate into a truststore; and any new https connection with the server should use the updated trust store.</p>
  
  <p>We are thinking that we should use two trust stores, one cacerts(default one shipped with jre) and other containing certificates of the servers that we add/remove dynamically in a list. This will make sure that we do not modify the default TrustStore(cacerts) of java.</p>
  
  <p>Please suggest how this can be achieved.
  Also, is there any way to use a specific trust store only for a particular thread in java, so  that other(existing and new) threads should still use the default java trueststore(cacerts), and one specific thread will use the particular truststore for the server.</p>
  
  <p>Thank you,
  Deepak</p>