URL crash (bug?)


#1

I needed to check the security behaviour for HTTPS connections. So I’ve written this tiny bit of code, and I’m surprised to see it crash (see debugger screenshot). It only crashes once in every 3 or 4 runs, I suspect it’s to do with opening the stream and not reading and data, or perhaps a timing/race condition of some kind.

Am I doing something wrong, or is it a genuine bug?

`
#include “…/JuceLibraryCode/JuceHeader.h”

using std::cout;

void testConnection(URL url)
{
    cout << url.toString(true) << "\n";

    int statusCode;

    StringPairArray responseHeaders;
    ScopedPointer<InputStream> stream = url.createInputStream(false, nullptr, nullptr, String::empty, 4000, &responseHeaders, &statusCode);

    if (stream)
        cout << "* OK, status code:" << statusCode << "\n";
    else
        cout << "* FAIL, status code:" << statusCode << "\n";

    cout << "\n";
 }


 int main (int argc, char* argv[])
 {

    cout << SystemStats::getOperatingSystemName() << "\n";
    cout << "HTTPS Behaviour Testing" << "\n";
    cout << "Expect: OK\n";
    testConnection(URL("https://badssl.com/"));

    cout << "---Expect: STRONG FAIL\n";
    testConnection(URL("https://self-signed.badssl.com/"));

    cout << "---Expect: STRONG FAIL\n";
    testConnection(URL("https://untrusted-root.badssl.com/"));

    cout << "---Expect: FAIL (expired cert)\n";
    testConnection(URL("https://expired.badssl.com/"));

    cout << "---Expect: FAIL (rubbish cipher)\n";
    testConnection(URL("https://rc4.badssl.com/"));

    cout << "---Expect: FAIL (rubbish security setting)\n";
    testConnection(URL("https://dh480.badssl.com/"));

    return 0;
}

`


#2

We hit the same thing here - will be posting a fix later today!