Skip to content

Commit 279b271

Browse files
committed
fix: ssl: should support self-signed certs on the proxy target (for local development) - fixes #17
1 parent ee4646d commit 279b271

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/lib/presets/m2/static/post_config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ xhr.open('POST', '/__bs/post');
44
xhr.setRequestHeader('Content-Type', 'application/json');
55
xhr.onload = function() {
66
if (xhr.status === 200) {
7-
console.log('sent');
7+
console.log('config-gen: merged RequireJS config sent');
88
}
99
else if (xhr.status !== 200) {
10-
alert('Request failed. Returned status of ' + xhr.status);
10+
console.log('config-gen: request failed, returned status of ' + xhr.status);
1111
}
1212
};
1313
xhr.send(JSON.stringify(requirejs.s.contexts._.config));

src/lib/proxy_transform.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
use actix::Actor;
2+
use actix_web::client::ClientConnector;
13
use actix_web::client::ClientRequestBuilder;
24
use actix_web::http::{header, HeaderMap, Method};
35
use actix_web::{client, dev, http, Error, HttpMessage, HttpRequest, HttpResponse};
46
use base64::encode;
57
use futures::Future;
68
use headers::clone_headers;
9+
use openssl::ssl::SslConnector;
10+
use openssl::ssl::{SslMethod, SslVerifyMode};
711
use preset::AppState;
812
use presets::m2::opts::{AuthBasic, M2PresetOptions};
913
use std::str;
@@ -49,11 +53,17 @@ pub fn proxy_req_setup(original_request: &HttpRequest<AppState>) -> ClientReques
4953
}
5054
);
5155

52-
// now choose how to handle it
53-
// if the client responds with a request we want to alter (such as HTML)
54-
// then we need to buffer the body into memory in order to apply regex's on the string
5556
let mut outgoing = client::ClientRequest::build();
57+
58+
// Since this is a development tool only, we're being risky here
59+
// and just disabling all SSL verifications
60+
let mut ssl_conn = SslConnector::builder(SslMethod::tls()).unwrap();
61+
ssl_conn.set_verify(SslVerifyMode::NONE);
62+
63+
let conn = ClientConnector::with_connector(ssl_conn.build()).start();
64+
5665
outgoing
66+
.with_connector(conn)
5767
.method(original_request.method().clone())
5868
.uri(next_url);
5969

0 commit comments

Comments
 (0)