Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1211

SSLSocketFactory constructor throwing java.lang.IllegalStateException: SSLContextImpl is not initialized

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 4.1.3
    • 4.2.2
    • Documentation
    • None
    • Java SE 1.7
      com.springsource.org.apache.httpcomponents.httpclient;version=4.1.1
      com.springsource.org.apache.httpcomponents.httpcore;version=4.1.0
      com.springsource.org.apache.commons.net;version=2.0.0

    Description

      The example illustrated in section 2.6. Protocol schemes (at: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html) fails to run with an IllegalArgumentException.

      import org.apache.http.conn.scheme.Scheme;
      import javax.net.ssl.SSLContext;
      import org.apache.http.conn.ssl.SSLSocketFactory;
      import org.apache.http.conn.scheme.Scheme;
      import org.apache.http.conn.scheme.SchemeRegistry;
      ...
      SSLSocketFactory sf = new SSLSocketFactory(
              SSLContext.getInstance("TLS"),
              SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
      Scheme https = new Scheme("https", 443, sf);
      

      The above fragment throws the following exception when executed

      java.lang.IllegalStateException: SSLContextImpl is not initialized
      	at sun.security.ssl.SSLContextImpl.engineGetSocketFactory(SSLContextImpl.java:182)
      	at javax.net.ssl.SSLContext.getSocketFactory(SSLContext.java:295)
      	at org.apache.http.conn.ssl.SSLSocketFactory.<init>(SSLSocketFactory.java:327)
      	at test.com.project.net.internal.http.apache.TestSSL.test3(TestSSL.java:95)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:601)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
      

      Am I missing something?

      Albert

      Attachments

        Activity

          People

            Unassigned Unassigned
            albertattard Albert Attard
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: