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

feat: TLS support for Spin. #114

Merged
merged 1 commit into from
Mar 2, 2022
Merged

Conversation

fibonacci1729
Copy link
Contributor

@fibonacci1729 fibonacci1729 commented Feb 28, 2022

closes #33

The spin-cli now supports the tls-key and tls-cert options, e.g.
spin up --tls-key <path/to/key> --tls-cert <path/to/cert> ...

For convenience, the following environment variables can be set in lieu of
their respective flags.

SPIN_TLS_CERT=<path/to/crt>
SPIN_TLS_KEY=<path/to/key>

NOTE: Explicitly set flags take precedence over the environment.

export RUST_LOG=spin_engine=info,spin_http,wact=info
export SPIN_TLS_CERT=crates/http/tests/local.crt.pem
export SPIN_TLS_KEY=crates/http/tests/local.key.pem
spin up --f templates/spin-http/spin.toml
curl -k https://127.0.0.1:3000/test/hello

Signed-off-by: Brian Hardock brian.hardock@fermyon.com
Co-authored-by: Michelle Dhanani michelle@fermyon.com

@fibonacci1729 fibonacci1729 changed the title ref(feat-33): TLS support for Spin. feat: TLS support for Spin. Feb 28, 2022
@fibonacci1729 fibonacci1729 marked this pull request as ready for review March 1, 2022 15:17
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/tls.rs Outdated Show resolved Hide resolved
crates/http/src/tests.rs Outdated Show resolved Hide resolved
src/commands/up.rs Outdated Show resolved Hide resolved
@radu-matei
Copy link
Member

There is one more thing that should be updated, and that is the header with the full URL of a request.
Currently, the scheme of the URL is always http — see

spin/crates/http/src/lib.rs

Lines 216 to 218 in 6651c2c

// TODO: check if TLS is enabled and change the scheme to "https".
let scheme = "http";
let full_url = format!("{}://{}{}", scheme, host, abs_path);

@fibonacci1729 fibonacci1729 force-pushed the feat-33 branch 2 times, most recently from 41bdf9f to e6ebc02 Compare March 1, 2022 21:34
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
crates/http/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Member

@radu-matei radu-matei left a comment

Choose a reason for hiding this comment

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

After Clippy is happy, LGTM.

Thanks!

src/commands/up.rs Outdated Show resolved Hide resolved
@fibonacci1729 fibonacci1729 force-pushed the feat-33 branch 2 times, most recently from 6a349cd to a1b05ad Compare March 2, 2022 16:22
The `spin-cli` now supports the `tls-key` and `tls-cert` options, e.g.
```spin up -tls-key <path/to/key> -tls-cert <path/to/cert> ...```

For convenience, the following environment variables can be set in lieu of
their respective flags.

```
SPIN_TLS_CERT=<path/to/cert>
SPIN_TLS_KEY=<path/to/key>
```

NOTE: Explicitly set flags take precedence over the environment.

```
export RUST_LOG=spin_engine=info,spin_http,wact=info
export SPIN_TLS_CERT=crates/http/tests/local.crt.pem
export SPIN_TLS_KEY=crates/http/tests/local.key.pem
spin up --app templates/spin-http/spin.toml
curl -k https://127.0.0.1:3000/test/hello
```

Signed-off-by: Brian Hardock <brian.hardock@fermyon.com>
Co-authored-by: Michelle Dhanani <michelle@fermyon.com>
Signed-off-by: Brian Hardock <brian.hardock@fermyon.com>
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.

Add TLS support for the HTTP trigger
3 participants