title: Access denied to setFactory by executing HttpsURLConnection.setDefaultSSLSocketFactory
body: <p>My scope is to send an https message trusting all certificates from a Java application on an Embedded Linux Module with a JVM (IcedTea6 1.11, Java Version 1.6.0_24) on it (as Info I have no access to this Embedded Linux or to the JVM to make any changes, I can only put compiled java application on it).</p>
  
  <p>I have only basic Java knowledge but I wrote from some examples found on the net an application that trust all certificates.
  At the beginning I had an error on the line </p>
  
  <blockquote>
    <p>SSLContext sc = SSLContext.getInstance("SSL");</p>
  </blockquote>
  
  <p>and I found out that the problem was that the SunJSSE Provider was not implemented in the JVM.
  My first step was to add the SunJSSE Provider </p>
  
  <blockquote>
    <p>Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());</p>
  </blockquote>
  
  <p>and after this if I read out the providers I can see that the adding was successfully and now I find the provider “SunJSSE version 1.6”.
  The Trust all Certificate Class is as following:</p>
  
  <pre><code>public final class TrustAllCertificates implements X509TrustManager, HostnameVerifier
  {
       public X509Certificate[] getAcceptedIssuers() {return null;}
       public void checkClientTrusted(X509Certificate[] certs, String authType) {}
       public void checkServerTrusted(X509Certificate[] certs, String authType) {}
       public boolean verify(String hostname, SSLSession session) {return true;}
       public static void install()
       {
           try
           {
              TrustAllCertificates trustAll = new TrustAllCertificates();
              final SSLContext sc = SSLContext.getInstance("SSL");
              sc.init(null, new TrustManager[]{trustAll}, new java.security.SecureRandom());
              HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
              HttpsURLConnection.setDefaultHostnameVerifier(trustAll);
           }
           catch (Exeption e)
           {
              JatLog.writeTempLog("Error: " + e.getMessage());
           }
       }
  }
  </code></pre>
  
  <p>Now I receive always the error </p>
  
  <blockquote>
    <p>access denied (java.lang.RuntimePermission setFactory)</p>
  </blockquote>
  
  <p>On executing the line </p>
  
  <blockquote>
    <p>HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());</p>
  </blockquote>
  
  <p>Someone has any idea about how to solve this?</p>