Skip to content

Commit 4c65c70

Browse files
committed
api: https
1 parent 6f5d43c commit 4c65c70

File tree

5 files changed

+6592
-5
lines changed

5 files changed

+6592
-5
lines changed

mpc-server/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
.env
1010

11-
/tmp/
11+
/tmp/
12+
/ssl-cert/

mpc-server/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ axum-extra = { version = "0.10.1", features = ["typed-header"] }
3434
dotenv = "0.15.0"
3535
toml = "0.8.22"
3636
hex = "0.4.3"
37+
axum-server = { version = "0.7.2", features = ["tls-rustls"] }

mpc-server/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ use axum::{
44
http::StatusCode,
55
routing::{get, post},
66
};
7+
use axum_server::tls_rustls::RustlsConfig;
78
use co_noir::{Address, Bn254, CrsParser, NetworkParty, PartyID, Utils};
89
use co_ultrahonk::prelude::ZeroKnowledge;
910
use rustls::pki_types::CertificateDer;
1011
use serde::Deserialize;
1112
use serde_json::json;
12-
use std::sync::Arc;
13+
use std::{net::SocketAddr, path::PathBuf, sync::Arc};
1314
use token::Token;
1415
use tower_http::{
1516
cors::{Any, CorsLayer},
@@ -54,6 +55,10 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
5455
.install_default()
5556
.unwrap();
5657

58+
let ssl_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("ssl-cert");
59+
let config =
60+
RustlsConfig::from_pem_file(ssl_dir.join("cert.pem"), ssl_dir.join("key.pem")).await?;
61+
5762
setup_db()?;
5863

5964
let parties = vec![
@@ -177,8 +182,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
177182
.on_response(trace::DefaultOnResponse::new().level(Level::INFO)),
178183
);
179184

180-
let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await?;
181-
axum::serve(listener, app).await?;
185+
// let listener = tokio::net::TcpListener::bind("0.0.0.0:8000").await?;
186+
// axum::serve(listener, app).await?;
187+
let addr = SocketAddr::from(([0, 0, 0, 0], 8000));
188+
axum_server::bind_rustls(addr, config)
189+
.serve(app.into_make_service())
190+
.await?;
182191

183192
Ok(())
184193
}

web-app/next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const isProduction = process.env.NODE_ENV === "production";
55
const nextConfig: NextConfig = {
66
reactStrictMode: true,
77
env: {
8-
NEXT_PUBLIC_API_URL: isProduction ? "http://94.130.176.20:8000" : "http://localhost:8000",
8+
NEXT_PUBLIC_API_URL: isProduction ? "https://94.130.176.20:8000" : "http://localhost:8000",
99
},
1010
};
1111

0 commit comments

Comments
 (0)