Gregory Schier
2025-08-02 09:37:28 -07:00
parent 23191dcfc3
commit b71bc2cc92
5 changed files with 19 additions and 12 deletions

View File

@@ -111,7 +111,7 @@ pub async fn send_http_request<R: Runtime>(
.referer(false)
.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);
match settings.proxy {

View File

@@ -4,8 +4,11 @@ use hyper_util::client::legacy::Client;
use hyper_util::rt::TokioExecutor;
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> {
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();
http.enforce_http(false);

View File

@@ -5,7 +5,7 @@ use rustls::{ClientConfig, DigitallySignedStruct, SignatureScheme};
use rustls_platform_verifier::BuilderVerifierExt;
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 config_builder = ClientConfig::builder_with_provider(arc_crypto_provider)
.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_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
}

View File

@@ -7,16 +7,19 @@ use tokio_tungstenite::tungstenite::handshake::client::Response;
use tokio_tungstenite::tungstenite::http::HeaderValue;
use tokio_tungstenite::tungstenite::protocol::WebSocketConfig;
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(
url: &str,
headers: HeaderMap<HeaderValue>,
validate_certificates: bool,
) -> crate::error::Result<(WebSocketStream<MaybeTlsStream<TcpStream>>, Response)> {
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 req_headers = req.headers_mut();
@@ -34,4 +37,4 @@ pub(crate) async fn ws_connect(
)
.await?;
Ok((stream, response))
}
}

View File

@@ -43,7 +43,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
return (
<VStack className="flex-col-reverse mb-3" space={3}>
{/* 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
color="primary"
variant="border"
@@ -135,9 +135,7 @@ function GrpcProtoSelectionDialogWithRequest({ request }: Props & { request: Grp
<table className="w-full divide-y divide-surface-highlight">
<thead>
<tr>
<th />
<th className="text-text-subtlest">Added File Paths</th>
<th />
<th className="text-text-subtlest" colSpan={3}>Added File Paths</th>
</tr>
</thead>
<tbody className="divide-y divide-surface-highlight">