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

[WIP] Local HTTPS Support #77

Merged
merged 1 commit into from
Mar 17, 2016
Merged

[WIP] Local HTTPS Support #77

merged 1 commit into from
Mar 17, 2016

Conversation

samgiles
Copy link
Contributor

Configuring TLS:

Create a certs/ directory containing your cert's private key and certificate:
The private_key and cert must be X509 files named crt.pem and private_key.pem

For example:

certs/
certs/test.knilxof.org/crt.pem
certs/test.knixof.org/private_key.pem

The directory that certs are found in can be configured in the configuration file under: foxbox.certficate_directory, by default the software will look for the certs directory in your current working directory.

You can disable TLS entirely using the --disable-tls command line argument.

@samgiles samgiles force-pushed the https-support branch 2 times, most recently from aac981b to 2639f1e Compare March 1, 2016 16:19
@samgiles
Copy link
Contributor Author

samgiles commented Mar 1, 2016

@fabricedesre can I get an initial review? Or suggest someone else.

I'm still trying to figure out how best to plumb in the hostname and certs from the controller as we'll need them before the server is started with this PR - we can change that, but maybe in a later PR. Also, following this we'll want to use LetsEncrypt, and pre-generate, or generate the certs on demand.

@fabricedesre
Copy link
Collaborator

I took avery quick look, but could you have a CertificateManager that you pass to the HttpServer instead of your current code?

@ferjm do you mind taking a look?

fn get_local_tls_key(&self) -> PathBuf;
fn get_local_tls_crt(&self) -> PathBuf;
fn get_remote_tls_key(&self) -> PathBuf;
fn get_remote_tls_crt(&self) -> PathBuf;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Fabrice mentioned, it'd be nice to move all this to a CertificateManager.

@ferjm
Copy link
Member

ferjm commented Mar 2, 2016

Great work Sam!

I think @michielbdejong has a more solid understanding of what's needed here. Michiel, Could you take a look, please? Thanks!

@michielbdejong
Copy link
Contributor

side note: I got https with self-signed certs, including QR, mDNS, and HSS, working with a nodejs proxy in #129 - may be useful as a reference.

@samgiles samgiles mentioned this pull request Mar 3, 2016
2 tasks
@michielbdejong
Copy link
Contributor

Latest scripts for DNS/TLS are in #163. The way it works:

{
  "self-signed": "https://ba25ea553e3ff05620224368284e4ae3.self-signed/a6450c08893/",
  "local": "https://dcaa0a22b76e30da2cfe0d10e94603ae.box.knilxof.org/",
  "mirrors": [
    "https://a.dcaa0a22b76e30da2cfe0d10e94603ae.box.knilxof.org/",
    "https://b.dcaa0a22b76e30da2cfe0d10e94603ae.box.knilxof.org/"
  ],
  "remote": "https://dcaa0a22b76e30da2cfe0d10e94603ae.box.knilxof.org/"
}

@samgiles
Copy link
Contributor Author

This requires the API compatible fork of Iron to allow custom SslContext support, see: iron/iron#433

A few of our sub-dependencies also rely on Iron, it is not enough to simply replace iron with a fork because of Cargo's dependency resolution, see: rust-lang/cargo#2385

@fabricedesre
Copy link
Collaborator

@samgiles I guess the alternative is to fork all the sub-dependencies that depend on Iron?

@samgiles
Copy link
Contributor Author

I just thought: I'm doing this locally by setting a .cargo/config with a path override. It overrides 'iron' with the implementation found at the configured path:

My .cargo/config looks like this:

paths = ["/Users/sam/code/rust/iron"]

I could add the iron into the repository and commit a config. @fabricedesre Does that sound reasonable as a work around?

@fabricedesre
Copy link
Collaborator

Yes, but can we override with a http or git url?

@samgiles
Copy link
Contributor Author

No, it needs to be a local path.

@fabricedesre
Copy link
Collaborator

So, something like:
paths = ["./iron-fork"]

@samgiles samgiles force-pushed the https-support branch 5 times, most recently from a8be92b to 24c8fa9 Compare March 15, 2016 15:39
@@ -33,4 +33,4 @@ script:
- $TRAVIS_BUILD_DIR/tools/execute-unit-tests-with-coverage
- jshint static/main/js/*.js static/setup/js/*.js test/selenium/*.js test/integration/lib/*.js test/integration/test/*.js
- npm run test-integration # starts foxbox and kills it within the test script
- (cargo run -- -l $BOX_LOCAL_NAME -p $BOX_PORT &> /dev/null &) ; npm run test-selenium
- (cargo run -- -l $BOX_LOCAL_NAME -p $BOX_PORT --disable-tls &> /dev/null &) ; npm run test-selenium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why test with --disable-tls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a solution for testing with self signed certs or real certs yet. We don't lose anything by disabling TLS for the tests for the time being.

In the future we need to figure out how to test properly (and cross platform) with certs. Maybe @JohanLorenzo or @npark-mozilla have some thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samgiles Just run selenium with a Firefox profile that has the security exception for the certificate you're using in the tests, see e.g. https://blog.codecentric.de/en/2010/02/selenium-and-ssl-certificates/.

I don't agree we don't lose anything - currently, we have a http API with a test. Once we merge this, we will have a https API without a test. :(

If some upstream change in Iron causes our API server to break on https but not on http, we will not be able to see that in our tests. Right?

Can you create a follow-up ticket to repair the selenium test?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this issue (#221) to create https test. Would like to find out how can I store / use certificates, will check the link you provided first on above comment.

Looks like for nodejs test, I need the .pem format of the cert/key/ca of the generated certificate somehow

if self.context_provider.is_none() {
self.context_provider = Some(context_provider);
self.notify_provider();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw (or log an error) if the context provider is set more than once?

@ferjm
Copy link
Member

ferjm commented Mar 16, 2016

This is an excellent job Sam!

I only added a few minor comments. Please, rebase and r=me with the comments addressed.

samgiles added a commit that referenced this pull request Mar 17, 2016
Local and remote HTTPS  with SNI support
@samgiles samgiles merged commit d8ccbfa into fxbox:master Mar 17, 2016
@samgiles samgiles deleted the https-support branch March 17, 2016 10:45
@michielbdejong michielbdejong mentioned this pull request Mar 17, 2016
5 tasks
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.

5 participants