Skip to content

Commit

Permalink
clippy n fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
wojciechsromek committed Oct 1, 2024
1 parent 8da8af4 commit df3513a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions iris-mpc-upgrade/src/bin/tcp_ssl_fixed_upgrade_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,29 @@ use iris_mpc_upgrade::{
use mpc_uniqueness_check::{bits::Bits, distance::EncodedBits};
use rand::SeedableRng;
use rand_chacha::ChaCha20Rng;
use std::{pin::Pin, time::Duration, fs, io::{self, Error as IoError}};
use std::io::ErrorKind;
use std::sync::Arc;
use rustls::pki_types::ServerName;
use rustls::{pki_types::ServerName, ClientConfig, RootCertStore};
use rustls_pemfile::certs;
use std::{
fs,
io::{self, Error as IoError, ErrorKind},
pin::Pin,
sync::Arc,
time::Duration,
};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
net::TcpStream,
time::timeout,
};
use rustls::{ClientConfig, RootCertStore};
use tokio_rustls::{client::TlsStream, TlsConnector, rustls};
use rustls_pemfile::certs;

use tokio_rustls::{client::TlsStream, rustls, TlsConnector};
use tracing::error;

async fn prepare_tls_stream_for_writing(address: &str) -> eyre::Result<TlsStream<TcpStream>> {
// The path to your custom CA certificate file (in PEM format)
let ca_cert_path = "/usr/local/share/ca-certificates/aws_orb_prod_private_ca.crt";

// Load the custom CA certificate
let ca_cert = fs::read(&ca_cert_path)?;
let ca_cert = fs::read(ca_cert_path)?;
let mut ca_reader = &ca_cert[..];

let mut root_cert_store = RootCertStore::empty();
Expand All @@ -61,10 +63,12 @@ async fn prepare_tls_stream_for_writing(address: &str) -> eyre::Result<TlsStream

// Perform the TLS handshake
println!("TLS connecting to {}", address);
let tls_stream = connector.connect(server_name, stream).await
let tls_stream = connector
.connect(server_name, stream)
.await
.map_err(|e| IoError::new(io::ErrorKind::Other, format!("TLS error: {}", e)))?;
println!("TLS connection established to {}", address);

Ok(tls_stream)
}

Expand Down
2 changes: 1 addition & 1 deletion iris-mpc-upgrade/src/bin/tcp_ssl_upgrade_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async fn prepare_tls_stream_for_writing(address: &str) -> eyre::Result<TlsStream
let tls_connector = TlsConnector::from(native_tls_connector);

println!("TLS connecting to {}", address);

// Perform the TLS handshake to establish a secure connection
let tls_stream: TlsStream<TcpStream> = tls_connector.connect(address, stream).await?;

Expand Down

0 comments on commit df3513a

Please sign in to comment.