Gregory Schier
2025-08-02 09:37:28 -07:00
parent 23191dcfc3
commit b71bc2cc92
5 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -111,7 +111,7 @@ pub async fn send_http_request<R: Runtime>(
.referer(false) .referer(false)
.tls_info(true); .tls_info(true);
let tls_config = yaak_http::tls::get_config(workspace.setting_validate_certificates); let tls_config = yaak_http::tls::get_config(workspace.setting_validate_certificates, true);
client_builder = client_builder.use_preconfigured_tls(tls_config); client_builder = client_builder.use_preconfigured_tls(tls_config);
match settings.proxy { match settings.proxy {
+4 -1
View File
@@ -4,8 +4,11 @@ use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor; use hyper_util::rt::TokioExecutor;
use tonic::body::BoxBody; use tonic::body::BoxBody;
// I think ALPN breaks this because we're specifying http2_only
const WITH_ALPN: bool = false;
pub(crate) fn get_transport(validate_certificates: bool) -> Client<HttpsConnector<HttpConnector>, BoxBody> { pub(crate) fn get_transport(validate_certificates: bool) -> Client<HttpsConnector<HttpConnector>, BoxBody> {
let tls_config = yaak_http::tls::get_config(validate_certificates); let tls_config = yaak_http::tls::get_config(validate_certificates, WITH_ALPN);
let mut http = HttpConnector::new(); let mut http = HttpConnector::new();
http.enforce_http(false); http.enforce_http(false);
+6 -3
View File
@@ -5,7 +5,7 @@ use rustls::{ClientConfig, DigitallySignedStruct, SignatureScheme};
use rustls_platform_verifier::BuilderVerifierExt; use rustls_platform_verifier::BuilderVerifierExt;
use std::sync::Arc; use std::sync::Arc;
pub fn get_config(validate_certificates: bool) -> ClientConfig { pub fn get_config(validate_certificates: bool, with_alpn: bool) -> ClientConfig {
let arc_crypto_provider = Arc::new(ring::default_provider()); let arc_crypto_provider = Arc::new(ring::default_provider());
let config_builder = ClientConfig::builder_with_provider(arc_crypto_provider) let config_builder = ClientConfig::builder_with_provider(arc_crypto_provider)
.with_safe_default_protocol_versions() .with_safe_default_protocol_versions()
@@ -19,8 +19,11 @@ pub fn get_config(validate_certificates: bool) -> ClientConfig {
.with_custom_certificate_verifier(Arc::new(NoVerifier)) .with_custom_certificate_verifier(Arc::new(NoVerifier))
.with_no_client_auth() .with_no_client_auth()
}; };
// Required for http/2 support
client.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()]; if with_alpn {
client.alpn_protocols = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
}
client client
} }
+6 -3
View File
@@ -7,16 +7,19 @@ use tokio_tungstenite::tungstenite::handshake::client::Response;
use tokio_tungstenite::tungstenite::http::HeaderValue; use tokio_tungstenite::tungstenite::http::HeaderValue;
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig; use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
use tokio_tungstenite::{ use tokio_tungstenite::{
connect_async_tls_with_config, Connector, MaybeTlsStream, WebSocketStream, Connector, MaybeTlsStream, WebSocketStream, connect_async_tls_with_config,
}; };
// Enabling ALPN breaks websocket requests
const WITH_ALPN: bool = false;
pub(crate) async fn ws_connect( pub(crate) async fn ws_connect(
url: &str, url: &str,
headers: HeaderMap<HeaderValue>, headers: HeaderMap<HeaderValue>,
validate_certificates: bool, validate_certificates: bool,
) -> crate::error::Result<(WebSocketStream<MaybeTlsStream<TcpStream>>, Response)> { ) -> crate::error::Result<(WebSocketStream<MaybeTlsStream<TcpStream>>, Response)> {
info!("Connecting to WS {url}"); info!("Connecting to WS {url}");
let tls_config = yaak_http::tls::get_config(validate_certificates); let tls_config = yaak_http::tls::get_config(validate_certificates, WITH_ALPN);
let mut req = url.into_client_request()?; let mut req = url.into_client_request()?;
let req_headers = req.headers_mut(); let req_headers = req.headers_mut();
@@ -34,4 +37,4 @@ pub(crate) async fn ws_connect(
) )
.await?; .await?;
Ok((stream, response)) Ok((stream, response))
} }
@@ -43,7 +43,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
return ( return (
<VStack className="flex-col-reverse mb-3" space={3}> <VStack className="flex-col-reverse mb-3" space={3}>
{/* Buttons on top so they get focus first */} {/* Buttons on top so they get focus first */}
<HStack space={2} justifyContent="start" className="flex-row-reverse"> <HStack space={2} justifyContent="start" className="flex-row-reverse mt-3">
<Button <Button
color="primary" color="primary"
variant="border" variant="border"
@@ -135,9 +135,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
<table className="w-full divide-y divide-surface-highlight"> <table className="w-full divide-y divide-surface-highlight">
<thead> <thead>
<tr> <tr>
<th /> <th className="text-text-subtlest" colSpan={3}>Added File Paths</th>
<th className="text-text-subtlest">Added File Paths</th>
<th />
</tr> </tr>
</thead> </thead>
<tbody className="divide-y divide-surface-highlight"> <tbody className="divide-y divide-surface-highlight">