hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HTTPCLIENT-1211) SSLSocketFactory constructor throwing java.lang.IllegalStateException: SSLContextImpl is not initialized
Date Mon, 02 Jul 2012 20:11:36 GMT

     [ https://issues.apache.org/jira/browse/HTTPCLIENT-1211?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Oleg Kalnichevski updated HTTPCLIENT-1211:
------------------------------------------

      Component/s:     (was: HttpClient)
                   Documentation
         Priority: Minor  (was: Major)
    Fix Version/s: 4.2.2

The code snippet in the tutorial is probably wrong. Apparently the SSL context must be explicitly
initialized  

---
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, null, null);
SSLSocketFactory sf = new SSLSocketFactory(
        sslcontext,
        SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
Scheme https = new Scheme("https", 443, sf);
---

Oleg
                
> SSLSocketFactory constructor throwing java.lang.IllegalStateException: SSLContextImpl
is not initialized
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1211
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1211
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Documentation
>    Affects Versions: 4.1.3
>         Environment: 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
>            Reporter: Albert Attard
>            Priority: Minor
>             Fix For: 4.2.2
>
>
> 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}}.
> {code:java}
> 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);
> {code}
> The above fragment throws the following exception when executed
> {code}
> 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)
> {code}
> Am I missing something? 
> Albert

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message