Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skewering HTTPS (mixed-mode loading problems) #56

Open
ecraven opened this issue Jun 30, 2015 · 8 comments
Open

Skewering HTTPS (mixed-mode loading problems) #56

ecraven opened this issue Jun 30, 2015 · 8 comments

Comments

@ecraven
Copy link

ecraven commented Jun 30, 2015

Is there a way to tell skewer to use https when skewering pages that are already https? Would make skewer-everything.js much more useful.

Thanks for creating this great emacs mode!

@skeeto
Copy link
Owner

skeeto commented Jun 30, 2015

This is one of the weak spots of Skewer, especially as the web moves
more and more towards HTTPS. Emacs has GnuTLS bindings but only for TLS
clients (i.e. url-retrieve). So at the moment there's no way to host an
HTTPS server within Emacs for Skewer short of writing an entire TLS
implementation in Emacs Lisp, which would be a far bigger project than
Skewer itself.

@ecraven
Copy link
Author

ecraven commented Jul 1, 2015

Would it be possible to solve this by using something like socat to forward an ssl socket to emacs?

@skeeto
Copy link
Owner

skeeto commented Jul 1, 2015

That's very likely to be possible. When Emacs is compiled without GnuTLS
support, it uses the gnutls command line program instead in a similar
way.

Since I don't need this myself at the moment, it's not something I plan
to implement, though this doesn't preclude anyone else from trying.

@unhammer
Copy link

unhammer commented Mar 14, 2017

I've used hitch as a workaround.

Run this once:

mkdir -p ~/.emacs.d/skewer-https/
cd ~/.emacs.d/skewer-https/

openssl req -nodes -newkey rsa:2048 -keyout skewer-hitch.key -out skewer-hitch.csr \
    -subj "/C=GB/ST=London/L=London/O=Acme Widgets/OU=IT Department/CN=localhost"
openssl x509 -req -days 365 -in skewer-hitch.csr -signkey skewer-hitch.key -out skewer-hitch.crt
cat skewer-hitch.key skewer-hitch.crt >skewer-hitch.pem

sudo apt install hitch

and run this after run-skewer:

(unless (get-buffer-process "*skewer-hitch*")
      (start-process "skewer-hitch" "*skewer-hitch*"
                     "hitch"
                     (format "--backend=[localhost]:%s" httpd-port)
                     "--frontend=[localhost]:38443"
                     (expand-file-name "~/.emacs.d/skewer-https/skewer-hitch.pem")))

In your web browser, go to https://localhost:38443/skewer and accept the self-signed cert, then change your bookmarklet to have the right port:

javascript:(function(){var%20d=document;var%20s=d.createElement('script');s.src='https://localhost:38443/skewer';d.body.appendChild(s);})()

(Make sure to reload the page first if you used your old bookmarklet – it'll point to the wrong port.)


I suppose we could add this as a function run-skewer-https that checks if the .pem exists (creating it if not) and runs hitch (giving some helpful message if it's not found)?

@skeeto
Copy link
Owner

skeeto commented Mar 14, 2017 via email

@unhammer
Copy link

Hm, I haven't noticed hitch doing any premature termination – maybe give that a try? It's quite small:

Installed-Size: 201 kB
Depends: libc6 (>= 2.14), libev4 (>= 1:4.04), libssl1.0.0 (>= 1.0.0), init-system-helpers (>= 1.18~), adduser

Why create a new cert on every startup? (Isn't that just creating more work for yourself?)
Firefox at least lets me save the cert when I go to localhost:38443/skewer and click Advanced, but since it's the same one each time, I only had to do it once (on that computer). Chrome I have no idea though.

@skeeto
Copy link
Owner

skeeto commented Mar 14, 2017

Hitch certainly seems like a cleaner solution than stunnel. I'll have to spend some time with it.

Why create a new cert on every startup?

That particular example is just for a throwaway sever. Plus, for documentation purposes, it captures the cert generation procedure (I can never remember). For Skewer it would probably make sense for a more persistent cert, hence it's important that the browser remembers the cert.

Firefox at least lets me save the cert

Oops, you're right. Upon closer examination I see that it's just my current configuration preventing the "permanently store" checkbox.

@unhammer
Copy link

unhammer commented Apr 5, 2017

Btw, for Chromium, I opened "Manage certificates → Authorities → Import" and selected my .pem file, ticking off "Trust this certificate for identifying websites". A bit more involved, but i can control Chromium too from Emacs now :)

Though for some reason, it sometimes first says GET https://localhost:38443/skewer/get net::ERR_INSECURE_RESPONSE in the console, but if I middle-click that (so it opens in a new tab) and click the bookmarklet again, it works. Very security 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants