title: Java and SSL - java.security.NoSuchAlgorithmException
body: <p>I've built a Java program as a front end for a database on a server, and I'm trying to use SSL to encrypt traffic between clients and the server.  Here is the command I issued to create the server certificate:</p>
  
  <pre><code>keytool -genkey -alias localhost -keyalg RSA -keypass kpass123 -storepass kpass123 -keystore keystore.jks
  </code></pre>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>System.setProperty("javax.net.ssl.keyStore",
                     "G:/Data/Android_Project/keystore.jks");
  
  System.setProperty("javax.net.ssl.keyPassword", "kpass123");
  
  SSLServerSocketFactory factory = 
      (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
  
  SSLServerSocket accessSocket = 
      (SSLServerSocket)factory.createServerSocket(DB_ACCESS_PORT);
  </code></pre>
  
  <p>When I try to run this, I catch this:</p>
  
  <blockquote>
    <p>java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)</p>
  </blockquote>
  
  <p>I've also found that the "KeyPairGenerator" service has algorithms DIFFIEHELLMAN, DSA, RSA available to it, while "SSLContext" has algorithms SSL, TLS, SSLV3, DEFAULT, TLSV1.</p>
  
  <p>Do I need to find some way to install RSA into the SSLContext service?  Am I even looking at the correct services?  Should I not be using RSA?</p>
  
  <p>I'm new to the whole SSL - Security - Certificates thing, and it just blows me away that each of these different services don't have the same algorithms when they are supposed to be accessing the same certificates.</p>