zhang-pc / mockwebserver

Automatically exported from code.google.com/p/mockwebserver
Apache License 2.0
0 stars 0 forks source link

propagate SSLHandshakeException instead of returning null #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In MockWebServer.readRequest when using an ssl socket factory, the following 
code block can swallow an SSLHandshakeException which makes debugging more 
difficult.  I think that should be instead propagated or at least logged.

        } catch (IOException streamIsClosed) {
            return null; // no request because we closed the stream
        }

Original issue reported on code.google.com by adrian.f...@gmail.com on 25 Jun 2013 at 3:40

GoogleCodeExporter commented 9 years ago
This issue shows up when cipher suites don't include 
"SSL_DH_anon_WITH_RC4_128_MD5"

I think a unit test showing correct use of useHttps would help divert others 
from stumbling even if the exception wasn't swallowed.

Using the attached file, a unit test would look like this:

server.useHttps(TrustingSSLSocketFactory.get(), false);
// setup and play server
HttpsURLConnection sslCon = (HttpsURLConnection) 
server.server.getUrl("").openConnection();
sslCon.setSSLSocketFactory(TrustingSSLSocketFactory.get());
// do stuff

If you agree with the idea, I can prepare a patch for this.

Original comment by adrian.f...@gmail.com on 25 Jun 2013 at 4:10

GoogleCodeExporter commented 9 years ago

Original comment by adrian.f...@gmail.com on 25 Jun 2013 at 4:11

Attachments:

GoogleCodeExporter commented 9 years ago
Dig. Have you submitted Google's CLA? This project is owned by those guys.

Original comment by limpbizkit on 29 Jun 2013 at 12:21

GoogleCodeExporter commented 9 years ago
yeah I have one on file.  will send patch in a bit!

Original comment by adrian.f...@gmail.com on 1 Jul 2013 at 3:12