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

Fix 1148 add native node https support #1202

Merged
merged 3 commits into from
Nov 25, 2012
Merged

Fix 1148 add native node https support #1202

merged 3 commits into from
Nov 25, 2012

Conversation

Wikinaut
Copy link
Contributor

Fix for issue #1148.

  • added the possibility to run the whole Etherpad-lite on native Node via SSL ( https:// ) protocol.
  • no further Apache or Nginx proxy server required
  • default = no SSL ( http:// protocol, unsecure password transmission)
  • added info message when the server starts whether SSL is disabled, or enabled and which server key file is used

@Wikinaut
Copy link
Contributor Author

The patch is "compatible". I mean, when not changing anything, the EPL runs in non-SSL mode as before as requested by John.

@JohnMcLear
Copy link
Member

Looks good to me, needs further testing , good job:)

@Wikinaut
Copy link
Contributor Author

Yep. Everything works with https:// ->>> except the Timeslider. Can you test that, please ? It now returns a BLANK page. Perhaps we are close to find the reason now....

Timeslider mega problem see #1077

@JohnMcLear
Copy link
Member

Just thinking how we handle passphrases?

@JohnMcLear
Copy link
Member

"key" : "c:\temp\wiki\etherpad-lite\ep.key", as a path doesnt work
changed to
"key" : "c:/temp/wiki/etherpad-lite/ep.key",
just needs documenting

@JohnMcLear
Copy link
Member

Generating the keys with puttygen doesn't work, can we document the correct steps in puttygen to generate good to use ssl keys?

@JohnMcLear
Copy link
Member

You need useful debug messages if a user puts in a bad path/key

[2012-11-24 17:24:36.284] [INFO] console - SSL -- server key file: c:   empwikietherpad-liteep.key
[2012-11-24 17:24:36.285] [INFO] console - SSL -- Certificate Authority's certificate file: c:  empwikietherpad-liteep.crt

fs.js:338
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'c:\temp\wiki\etherpad-lite\   empwikietherpad-liteep.key'
    at Object.fs.openSync (fs.js:338:18)
    at Object.fs.openSync (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:68:26)
    at Object.fs.openSync (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node_modules\graceful-fs\graceful-fs.js:74:27)
    at Object.fs.openSync (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node_modules\npm-registry-client\node_modules\graceful-fs\graceful-fs.js:68:26)
    at Object.fs.readFileSync (fs.js:182:15)
    at Object.exports.restartServer (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node\hooks\express.js:60:15)
    at Object.exports.createServer [as hook_fn] (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node\hooks\express.js:32:11)
    at normalizedhook (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:15:27)
    at hookCallWrapper (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:21:14)
    at exports.callAll (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:75:12)

C:\temp\wiki\etherpad-lite>nano settings.jso

C:\temp\wiki\etherpad-lite>start.bat

C:\temp\wiki\etherpad-lite>node node_modules\ep_etherpad-lite\node\server.js
[2012-11-24 17:25:23.638] [WARN] console - DirtyDB is used. This is fine for testing but not recommended for production.
[2012-11-24 17:25:24.249] [INFO] console - Installed plugins: ep_etherpad-lite
[2012-11-24 17:25:24.281] [INFO] console - Your Etherpad Lite git version is 43980ff
[2012-11-24 17:25:24.282] [INFO] console - Report bugs at https://github.com/ether/etherpad-lite/issues
[2012-11-24 17:25:24.287] [INFO] console - SSL -- enabled
[2012-11-24 17:25:24.288] [INFO] console - SSL -- server key file: c:/temp/wiki/etherpad-lite/ep.key
[2012-11-24 17:25:24.289] [INFO] console - SSL -- Certificate Authority's certificate file: c:/temp/wiki/etherpad-lite/ep.crt

crypto.js:84
      c.context.setKey(options.key);
                ^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Object.exports.createCredentials (crypto.js:84:17)
    at Server (tls.js:1031:28)
    at new Server (https.js:33:14)
    at Object.exports.createServer (https.js:48:10)
    at Object.exports.restartServer (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node\hooks\express.js:65:20)
    at Object.exports.createServer [as hook_fn] (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\node\hooks\express.js:32:11)
    at normalizedhook (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:15:27)
    at hookCallWrapper (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:21:14)
    at exports.callAll (C:\temp\wiki\etherpad-lite\node_modules\ep_etherpad-lite\static\js\pluginfw\hooks.js:75:12)
    at Array.map (native)

C:\temp\wiki\etherpad-lite>

is not good enough

@Wikinaut
Copy link
Contributor Author

ok, will do so !

@JohnMcLear
Copy link
Member

I can't test timeslider until we have good docs on how to deploy so this one is back at ya @Wikinaut, let me know once you are good for me to continue

@Wikinaut
Copy link
Contributor Author

PuttyGen and OpenSSl are not 100% compatible for generating server keys. This is a well known problem and has nothing to do with the present patch. Give me time... to document

@Wikinaut
Copy link
Contributor Author

@johnyma22 you wrote I can't test timeslider until we have good docs...

As mentioned 1000 times, p l e a s e visit your own pad http://beta.primarypad.com/p/test/timeslider where you will certainly notice, that it does not work as expected.

@Wikinaut
Copy link
Contributor Author

@johnyma22

OpenSSH under Linux cannot read ppk files generated by PuTTY under Windows....

Use these instructions to generate and sign server keys, one of the best descriptions on the web

Creating Certificate Authorities and self-signed SSL certificates

http://web.archive.org/web/20110704035103/http://www.tc.umn.edu/~brams006/selfsign.html

I just contacted the author for his expressed permission to re-use his description.

@Wikinaut
Copy link
Contributor Author

@johnyma22 > You need useful debug messages if a user puts in a bad path/key

Not my task, SSL works now for me, and I presented the fine basic code in my pull request; the fine tuning of error messages can be done by others, respectfully stated(*). Running an APACHE2 with wrong keys, you will find also strange misleading error messages - which nobody of the Apache foundation has fixed in the last 20 years.

(*) I am not yet in a position to being able to supply a perfect code for error conditions like the one you have encountered (lack of knowledge, sorry). If you can add some error robustness to the crypto.js calls, I will very much appreciate this.

@JohnMcLear
Copy link
Member

@Wikinaut As mentioned 1000 times you still haven't provided steps to replicate the bug. You just keep providing a URL that we know is broken. Plus this has nothing to do with this pull request so let's keep things on topic.

@JohnMcLear
Copy link
Member

@Wikinaut okay bump me when docs are ready :) thanks.

@JohnMcLear
Copy link
Member

Also RE useful debug this wont be merged until it's clear to users how to set this up, even if the debug help is provided in a wiki "how to setup native SSL support" or whatever you create that would be okay enough to see it merged. It's really important that people can get past any barriers that SSL may introduce :)

Cheers

@Wikinaut
Copy link
Contributor Author

@johnyma22 Regarding this

"key" : "c:\temp\wiki\etherpad-lite\ep.key", as a path doesnt work
changed to
"key" : "c:/temp/wiki/etherpad-lite/ep.key",
just needs documenting

.... isn't that an issue to be reported to the people responsible for "fs.readFileSync( filename )", which apparently does ignore the operation-system specific path separators?

I thought, that filenames and paths are handled transparently for the user, system independently. Will investigate, why it isn't.

@Wikinaut
Copy link
Contributor Author

@johnyma22

Also RE useful debug this wont be merged until it's clear to users how to set this up, even if the debug help is provided in a wiki "how to setup native SSL support" or whatever you create that would be okay enough to see it merged. It's really important that people can get past any barriers that SSL may introduce :)

John, SSL is web standard. Every admin knows. Why should we duplicate information which is available on the net, especially as it is NOT EPL default, as requested by you. Honestly, to explain here in the EPL context, how SSL works and how keys to be generated goes beyond the scope of my work and litters the EPL pages with unneeded information.

But to please you, I will set up a new "ether" wiki page

@joker-x
Copy link
Contributor

joker-x commented Nov 24, 2012

How to configure nginx or varnish is available on the net too, but it is usefull collect all relative configuration in the wiki. I think it is the same case. Often, features are not used because the newbie user not found good documentation. And this is a pity.

👍 new wiki page!

@JohnMcLear
Copy link
Member

openssl.exe is available by default in Windows?

@JohnMcLear
Copy link
Member

The wiki page needs a big warning saying "DO NOT COPY/PASTE THESE STEPS AS IT WONT WORK"

@JohnMcLear
Copy link
Member

@Wikinaut Works great and timeslider is fine -- Good job :) Once my final concerns have been addressed this will be good to merge. Today or tomorrow I expect

@Wikinaut
Copy link
Contributor Author

I just want to add this here:

  • there may be problems coming up when a plugin reads foreign http: resources in the context of the https secured pad
  • I observed this effect just right now with the ep_tables plugin
  • The browser then changes the "lock" symbol to "unlock".

I inspected the connection and the generated page code. The problem stems from the fact that ep_tables fetches via http these resources

<link rel='stylesheet' href='http://yui.yahooapis.com/2.9.0/build/fonts/fonts-min.css' type='text/css' />   
<link rel='stylesheet' href='http://yui.yahooapis.com/2.9.0/build/slider/assets/skins/sam/slider.css' type='text/css' />    
...
<link rel='stylesheet' href='http://yui.yahooapis.com/2.9.0/build/colorpicker/assets/skins/sam/colorpicker.css' type='text/css' />

I my view this currently should not prevent you to pull my current patch.

(updated)

@Wikinaut
Copy link
Contributor Author

As consequence from the previous comment,

a secure EPL set up demands that also all required resources and frameworks come via https.

@disy-mk
Copy link
Contributor

disy-mk commented Nov 24, 2012

there may be problems coming up when a plugin breaks out of the iframe and uses a http:// instead of https:// connection.
I observed this effect just right now with the ep_tables plugin https://github.com/clkao/ep_tables
The browser then changes the "lock" symbol to "unlock".

Also saw that with ep_sketchspace; (was using EPL behind stunnel/nginx-combo to have "working" SSL)

@Wikinaut
Copy link
Contributor Author

I could fix the problem !

Solution is: use protocol-independent urls "//" everywhere

MediaWiki has went to this in the last year, and all urls have been replaced by "//". The procedure is explained for example explained here http://stackoverflow.com/a/550164 "Is it valid to replace http:// with // in a script src=“http://…”?"

[updated]
removed the link to proof of concept

@joker-x
Copy link
Contributor

joker-x commented Nov 24, 2012

A good trick to solve this problem is let the navigator choose proper protocol. For example, to load jquery from google CDN you can use:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

In SSL conection the navigator go to https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js or a standar conection to http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js

@Wikinaut
Copy link
Contributor Author

mid-air collision !
I just posted THE solution.

@joker-x
Copy link
Contributor

joker-x commented Nov 24, 2012

we are sincronized @Wikinaut :)

@Wikinaut
Copy link
Contributor Author

@joker-x thanks. I also found this, and documented it, and added as a proof of concept my recent fork of ep_tables where I successfully applied the protocol independent url method. ty

@Wikinaut
Copy link
Contributor Author

[updated]
removed the link to proof of concept

@joker-x
Copy link
Contributor

joker-x commented Nov 24, 2012

using these protocol independent urls we can remove a few javascript check protocol lines :D

@Wikinaut
Copy link
Contributor Author

I was right - but wrong with my proof of concept, because the yahoo server does not deliver content when requested via https:// .

Important

Of course keep in mind, that the protocol-independent url only works, if the resource servers actually deliver their contents over http:// and also over https:// ,

@Wikinaut
Copy link
Contributor Author

I can now officially confirm, that "it" works.

"it" means:

when copying and unzipping http://yuilibrary.com/downloads/yui2/yui_2.9.0.zip to a server which delivers the stuff via https: (I used a non-Node server, running Apache), the protocol independent urls in my ep_tables fork https://github.com/Wikinaut/ep_tables/commit/c65c05924cbac89aa06e7ccbd2f92e76e2708a43 do work, and the ep_tables plugin in my SSL-EPL does work.

@JohnMcLear
Copy link
Member

/me is confused why we need yui, am I missing something?

@Wikinaut
Copy link
Contributor Author

@johnyma22 we do NOT need it.

ep_tables needs it and loads it. I discovered the "break out SSL" when having ep_tables activated. Now everything is clear and safe. Let me know if you need more details (I wanted to be short)

I installed locally you ONLY for the final test.

@Wikinaut
Copy link
Contributor Author

I installed yui locally only for my test. Everything is clear. You can "pull"

JohnMcLear added a commit that referenced this pull request Nov 25, 2012
…-support

Fix 1148 add native node https support
@JohnMcLear JohnMcLear merged commit fdf0b1a into ether:develop Nov 25, 2012
@Wikinaut
Copy link
Contributor Author

may be a small step for epl but a giant leap for mankind. Very kind. ty

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

Successfully merging this pull request may close these issues.

4 participants