Skip to content

Commit 3e6140e

Browse files
committed
Fixes attested-tls crate branch
1 parent ad6ff18 commit 3e6140e

4 files changed

Lines changed: 10 additions & 68 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

attested-tls/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ http = "1.3.1"
1818
serde_json = "1.0.145"
1919
tracing = "0.1.41"
2020
parity-scale-codec = "3.7.5"
21-
attestation = { git = "https://github.com/flashbots/attested-tls", branch = "peg/add-attestation-crate" }
21+
attestation = { git = "https://github.com/flashbots/attested-tls", branch = "peg/attested-tls-crate" }
2222

2323
# Used for websocket support
2424
tokio-tungstenite = { version = "0.28.0", optional = true }
@@ -40,7 +40,7 @@ rcgen = { version = "0.14.5", optional = true }
4040
[dev-dependencies]
4141
rcgen = "0.14.5"
4242
tempfile = "3.23.0"
43-
attestation = { git = "https://github.com/flashbots/attested-tls", branch = "peg/add-attestation-crate", features = ["mock"] }
43+
attestation = { git = "https://github.com/flashbots/attested-tls", branch = "peg/attested-tls-crate", features = ["mock"] }
4444

4545
[features]
4646
default = ["ws", "rpc"]

src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ async fn main() -> anyhow::Result<()> {
316316
CliCommand::GetTlsCert {
317317
server,
318318
tls_ca_certificate,
319-
out_measurements,
319+
out_measurements: _, // TODO
320320
} => {
321321
let remote_tls_cert = match tls_ca_certificate {
322322
Some(remote_cert_filename) => Some(
@@ -416,12 +416,10 @@ fn load_tls_cert_and_key_server(
416416
cert_chain.ok_or(anyhow!("Private key given but no certificate chain"))?,
417417
private_key,
418418
)
419+
} else if cert_chain.is_some() {
420+
Err(anyhow!("Certificate chain provided but no private key"))
419421
} else {
420-
if cert_chain.is_some() {
421-
Err(anyhow!("Certificate chain provided but no private key"))
422-
} else {
423-
Err(anyhow!("No private key provided"))
424-
}
422+
Err(anyhow!("No private key provided"))
425423
}
426424
}
427425

src/test_helpers.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Helper functions used in tests
22
use axum::response::IntoResponse;
33
use std::{
4-
collections::HashMap,
5-
net::{IpAddr, SocketAddr},
4+
net::SocketAddr,
65
sync::{Arc, Once},
76
};
87
use tokio::net::TcpListener;
@@ -15,29 +14,6 @@ use tracing_subscriber::{EnvFilter, fmt};
1514

1615
static INIT: Once = Once::new();
1716

18-
use attestation::measurements::{DcapMeasurementRegister, MultiMeasurements};
19-
20-
/// Helper to generate a self-signed certificate for testing
21-
pub fn generate_certificate_chain(
22-
ip: IpAddr,
23-
) -> (Vec<CertificateDer<'static>>, PrivateKeyDer<'static>) {
24-
let mut params = rcgen::CertificateParams::new(vec![]).unwrap();
25-
params.subject_alt_names.push(rcgen::SanType::IpAddress(ip));
26-
params
27-
.subject_alt_names
28-
.push(rcgen::SanType::DnsName(ip.to_string().try_into().unwrap()));
29-
params
30-
.distinguished_name
31-
.push(rcgen::DnType::CommonName, ip.to_string());
32-
33-
let keypair = rcgen::KeyPair::generate().unwrap();
34-
let cert = params.self_signed(&keypair).unwrap();
35-
36-
let certs = vec![CertificateDer::from(cert)];
37-
let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from(keypair.serialize_der()));
38-
(certs, key)
39-
}
40-
4117
/// Helper to generate a self-signed certificate for testing with a DNS subject name
4218
pub fn generate_certificate_chain_for_host(
4319
host: &str,

0 commit comments

Comments
 (0)