title: Java Exception on SSLSocket creation
body: <p>In the code: </p>
  
  <pre><code>System.setProperty("javax.net.ssl.trustStore", cacerts);
  System.setProperty("javax.net.ssl.trustStorePassword", pwdCacerts);
  
  SSLSocketFactory sslsocketfactory = (SSLSocketFactory)  SSLSocketFactory.getDefault();
  SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("localhost", port);
  </code></pre>
  
  <p>I obtain a Java Exception: </p>
  
  <pre><code>java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
      at javax.net.ssl.DefaultSSLSocketFactory.throwException(Unknown Source)
      at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
      at PracticaRO.Cliente.main(Cliente.java:24)
  Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
      at java.security.Provider$Service.newInstance(Unknown Source)
      at sun.security.jca.GetInstance.getInstance(Unknown Source)
      at sun.security.jca.GetInstance.getInstance(Unknown Source)
      at javax.net.ssl.SSLContext.getInstance(Unknown Source)
      at javax.net.ssl.SSLContext.getDefault(Unknown Source)
      at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
      at PracticaRO.Cliente.main(Cliente.java:23)
  Caused by: java.io.IOException: Invalid keystore format
      at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
      at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
      at java.security.KeyStore.load(Unknown Source)
      at sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(Unknown Source)
      at sun.security.ssl.SSLContextImpl$DefaultSSLContext.getDefaultTrustManager(Unknown Source)
      at sun.security.ssl.SSLContextImpl$DefaultSSLContext.&lt;init&gt;(Unknown Source)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at java.lang.Class.newInstance(Unknown Source)
      ... 7 more
  </code></pre>
  
  <p>It worked fine until I imported a new public key into cacerts with <code>-keytool -import -keystore cacerts -alias kpServer type JCEKS -file Server.cer</code> what caused the exception above.</p>
  
  <p>Thanks in advance for any help.</p>