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 18 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
6 changes: 5 additions & 1 deletion packages/cli/src/serve/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use hyper_util::{
client::legacy::{self, connect::HttpConnector},
rt::TokioExecutor,
};
use rustls::crypto::ring;

#[derive(Debug, Clone)]
struct ProxyClient {
Expand All @@ -24,7 +25,10 @@ struct ProxyClient {

impl ProxyClient {
fn new(url: Uri) -> Self {
let _ = rustls::crypto::ring::default_provider().install_default();
// Need to initialize the default crypto provider before we start the server
// https://github.com/rustls/rustls/issues/1938
// The thread which wins will install the provider
let _ = ring::default_provider().install_default();
let https = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.unwrap()
Expand Down
12 changes: 10 additions & 2 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,13 @@ 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();

// 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)
// The thread which wins will install the provider
let _ = ring::default_provider().install_default();

let router = build_devserver_router(
args,
krate,
Expand Down Expand Up @@ -252,7 +260,7 @@ impl WebServer {
BuildStage::Failed => self.send_reload_failed().await,
BuildStage::Restarting => self.send_reload_start().await,
BuildStage::Initializing => {}
BuildStage::InstallingTooling {} => {}
BuildStage::InstallingTooling => {}
BuildStage::Compiling {
current,
total,
Expand All @@ -267,7 +275,7 @@ impl WebServer {
self.send_build_status().await;
}
}
BuildStage::OptimizingWasm {} => {}
BuildStage::OptimizingWasm => {}
BuildStage::Aborted => {}
BuildStage::CopyingAssets { .. } => {}
_ => {}
Expand Down