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

fixed the https functionality broken from rustls upgrade #3764

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions packages/cli/src/serve/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,19 @@ impl Output {

self.render_feature_list(frame, app_features, state);

// todo(jon) should we write https ?
let address = match state.server.displayed_address() {
Some(address) => format!("http://{}", address).blue(),
None => "no server address".dark_gray(),
};
// Render the server address
let address = state
.server
.displayed_address()
.map(|addr| {
let scheme = if state.krate.config.web.https.enabled.unwrap_or_default() {
"https"
} else {
"http"
};
format!("{}://{}", scheme, addr).blue()
})
.unwrap_or_else(|| "no server address".dark_gray());

frame.render_widget_ref(
Paragraph::new(Line::from(vec![
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/serve/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ struct ProxyClient {

impl ProxyClient {
fn new(url: Uri) -> Self {
let _ = rustls::crypto::ring::default_provider().install_default();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.unwrap()
Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/serve/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use futures_util::{
StreamExt,
};
use hyper::HeaderMap;
use rustls::crypto::ring;
use serde::{Deserialize, Serialize};
use std::{
convert::Infallible,
Expand Down Expand Up @@ -111,6 +112,14 @@ impl WebServer {

// Set up the router with some shared state that we'll update later to reflect the current state of the build
let build_status = SharedStatus::new_with_starting_build();

// Optionally need to initialize the default crypto provider before we start the server
// https://github.com/rustls/rustls/issues/1938
// This is needed for WSS (dev proxy) / HTTPS (local dev server test)
ring::default_provider()
.install_default()
.expect("Failed to install rustls crypto provider");

let router = build_devserver_router(
args,
krate,
Expand Down