XMLHttpRequest refuses to connect to localhost over HTTPS

1,243 views
Skip to first unread message

Artem Mindrov

unread,
Jul 10, 2013, 6:27:15 AM7/10/13
to chromium-...@chromium.org
Having problems with the code in the attached script. For some reason, xhr fails to POST to the specified URL (https://127.0.0.1:3000/mobile/sessions). In the readystate handler I can see its state is set to 4 and status is 0. No error text, no response text.

Network tab in chrome dev tools shows that the requests are canceled.

In my mainfest.json file, I've tried to set permissions for <all_urls>, https://*/*, https://localhost/* and https://127.0.0.1/*, to no avail. However, if I make a request to any other remote server (e.g. my staging application hosted on Heroku), it goes fine.

The script is linked to from a popup page, if that makes any difference.

Using the latest Chrome to date (28.0.1500.71).

Appreciate any help.
Thanks.
auth.js

Adam Barth

unread,
Jul 10, 2013, 3:34:13 PM7/10/13
to Artem Mindrov, Chromium-extensions
What does it mean to connect to 127.0.0.1 over HTTPS?  Do you have a certificate for 127.0.0.1?  If you have one, can anyone get one?

Adam




--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/.
For more options, visit https://groups.google.com/a/chromium.org/groups/opt_out.
 
 

Artem Mindrov

unread,
Jul 10, 2013, 10:01:47 PM7/10/13
to chromium-...@chromium.org, Artem Mindrov
I have a Thin server running locally on port 3000 with a self-signed cert.

Artem
Message has been deleted

Artem Mindrov

unread,
Jul 18, 2013, 7:08:19 AM7/18/13
to chromium-...@chromium.org
So for those who run into the same problem: the culprit was indeed the self-signed certificate. For some reason XHR fails silently when a certificate error occurs. So I had to use the same Comodo verified cert I was using on production;

thin start --ssl --ssl-key-file cert\server.key --ssl-cert-file cert\server.crt --ssl-verify

To make sure domains match, I had to use a rule in Fiddler's OnBeforeRequest() (I'm on Windows) and enable it to capture HTTPS traffic:

    if (oSession.HTTPMethodIs("
CONNECT") && (oSession.host == "my.host.com")) {
        oSession.host = "127.0.0.1:3000";
    }

If there is a simpler solution, I'd like to hear it.
Reply all
Reply to author
Forward
0 new messages