Skip to content

Commit c907f62

Browse files
committed
Add comments for missing items
1 parent e28d69e commit c907f62

File tree

1 file changed

+91
-24
lines changed

1 file changed

+91
-24
lines changed

src/main.rs

Lines changed: 91 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ use attested_tls_proxy::{
1414
struct Cli {
1515
#[clap(subcommand)]
1616
command: CliCommand,
17+
// TODO missing:
18+
// Name: "log-json",
19+
// Value: false,
20+
// Usage: "log in JSON format",
21+
//
22+
// Name: "log-debug",
23+
// Value: true,
24+
// Usage: "log debug messages",
25+
//
26+
// Name: "log-dcap-quote",
27+
// EnvVars: []string{"LOG_DCAP_QUOTE"},
28+
// Value: false,
29+
// Usage: "log dcap quotes to folder quotes/",
1730
}
1831

1932
#[derive(Subcommand, Debug, Clone)]
@@ -22,33 +35,78 @@ enum CliCommand {
2235
Client {
2336
/// Socket address to listen on
2437
#[arg(short, long, default_value = "0.0.0.0:0")]
25-
address: SocketAddr,
38+
listen_addr: SocketAddr,
2639
/// The hostname:port or ip:port of the proxy server (port defaults to 443)
27-
server: String,
40+
// TODO `cvm-reverse-proxy` accepts with with protocol, eg: `https://localhost:80`
41+
target_addr: String,
2842
/// The path to a PEM encoded private key for client authentication
2943
#[arg(long)]
30-
private_key: Option<PathBuf>,
44+
tls_private_key_path: Option<PathBuf>,
3145
/// The path to a PEM encoded certificate chain for client authentication
3246
#[arg(long)]
33-
cert_chain: Option<PathBuf>,
47+
tls_certificate_path: Option<PathBuf>,
48+
/// Type of attestaion to present (dafaults to none)
49+
/// If other than None, a TLS key and certicate must also be given
50+
#[arg(long)]
51+
client_attestation_type: Option<String>,
52+
// Value: string(proxy.AttestationNone),
53+
// TODO missing:
54+
// Name: "tls-ca-certificate",
55+
// Usage: "additional CA certificate to verify against (PEM) [default=no additional TLS certs]. Only valid with --verify-tls.",
56+
//
57+
//
58+
// Name: "server-measurements",
59+
// Usage: "optional path to JSON measurements enforced on the server",
60+
//
61+
// Name: "override-azurev6-tcbinfo",
62+
// Value: false,
63+
// EnvVars: []string{"OVERRIDE_AZUREV6_TCBINFO"},
64+
// Usage: "Allows Azure's V6 instance outdated SEAM Loader",
65+
//
66+
// Name: "dev-dummy-dcap",
67+
// EnvVars: []string{"DEV_DUMMY_DCAP"},
68+
// Usage: "URL of the remote dummy DCAP service. Only with --client-attestation-type dummy.",
3469
},
3570
/// Run a proxy server
3671
Server {
3772
/// Socket address to listen on
3873
#[arg(short, long, default_value = "0.0.0.0:0")]
39-
address: SocketAddr,
74+
listen_addr: SocketAddr,
4075
/// Socket address of the target service to forward traffic to
41-
target_address: SocketAddr,
76+
target_addr: SocketAddr,
4277
/// The path to a PEM encoded private key
4378
#[arg(long)]
44-
private_key: PathBuf,
79+
tls_private_key_path: PathBuf,
4580
/// The path to a PEM encoded certificate chain
4681
#[arg(long)]
47-
cert_chain: PathBuf,
82+
tls_certificate_path: PathBuf,
4883
/// Whether to use client authentication. If the client is running in a CVM this must be
4984
/// enabled.
5085
#[arg(long)]
5186
client_auth: bool,
87+
// TODO missing:
88+
// Name: "listen-addr-healthcheck",
89+
// EnvVars: []string{"LISTEN_ADDR_HEALTHCHECK"},
90+
// Value: "",
91+
// Usage: "address to listen on for health checks",
92+
//
93+
// Name: "server-attestation-type",
94+
// EnvVars: []string{"SERVER_ATTESTATION_TYPE"},
95+
// Value: string(proxy.AttestationAuto),
96+
// Usage: "type of attestation to present (" + proxy.AvailableAttestationTypes + "). Set to " + string(proxy.AttestationDummy) + " to connect to a remote tdx quote provider. Defaults to automatic detection.",
97+
//
98+
// Name: "client-measurements",
99+
// EnvVars: []string{"CLIENT_MEASUREMENTS"},
100+
// Usage: "optional path to JSON measurements enforced on the client",
101+
//
102+
// Name: "override-azurev6-tcbinfo",
103+
// Value: false,
104+
// EnvVars: []string{"OVERRIDE_AZUREV6_TCBINFO"},
105+
// Usage: "Allows Azure's V6 instance outdated SEAM Loader",
106+
//
107+
// Name: "dev-dummy-dcap",
108+
// EnvVars: []string{"DEV_DUMMY_DCAP"},
109+
// Usage: "URL of the remote dummy DCAP service. Only with --server-attestation-type dummy.",
52110
},
53111
/// Retrieve the attested TLS certificate from a proxy server
54112
GetTlsCert {
@@ -63,24 +121,32 @@ async fn main() -> anyhow::Result<()> {
63121

64122
match cli.command {
65123
CliCommand::Client {
66-
address,
67-
server,
68-
private_key,
69-
cert_chain,
124+
listen_addr,
125+
target_addr,
126+
tls_private_key_path,
127+
tls_certificate_path,
128+
client_attestation_type,
70129
} => {
71-
let tls_cert_and_chain = if let Some(private_key) = private_key {
130+
let tls_cert_and_chain = if let Some(private_key) = tls_private_key_path {
72131
Some(load_tls_cert_and_key(
73-
cert_chain.ok_or(anyhow!("Private key given but no certificate chain"))?,
132+
tls_certificate_path
133+
.ok_or(anyhow!("Private key given but no certificate chain"))?,
74134
private_key,
75135
)?)
76136
} else {
77137
ensure!(
78-
cert_chain.is_none(),
138+
tls_certificate_path.is_none(),
79139
"Certificate chain given but no private key"
80140
);
81141
None
82142
};
83143

144+
// TODO
145+
let _client_attestation_type = match client_attestation_type {
146+
Some(_) => AttestationType::QemuTdx,
147+
None => AttestationType::None,
148+
};
149+
84150
let quote_verifier = DcapTdxQuoteVerifier {
85151
attestation_type: AttestationType::Dummy,
86152
accepted_platform_measurements: None,
@@ -94,8 +160,8 @@ async fn main() -> anyhow::Result<()> {
94160

95161
let client = ProxyClient::new(
96162
tls_cert_and_chain,
97-
address,
98-
server,
163+
listen_addr,
164+
target_addr,
99165
NoQuoteGenerator,
100166
quote_verifier,
101167
)
@@ -108,22 +174,23 @@ async fn main() -> anyhow::Result<()> {
108174
}
109175
}
110176
CliCommand::Server {
111-
address,
112-
target_address,
113-
private_key,
114-
cert_chain,
177+
listen_addr,
178+
target_addr,
179+
tls_private_key_path,
180+
tls_certificate_path,
115181
client_auth,
116182
} => {
117-
let tls_cert_and_chain = load_tls_cert_and_key(cert_chain, private_key)?;
183+
let tls_cert_and_chain =
184+
load_tls_cert_and_key(tls_certificate_path, tls_private_key_path)?;
118185
let local_attestation = DcapTdxQuoteGenerator {
119186
attestation_type: AttestationType::Dummy,
120187
};
121188
let remote_attestation = NoQuoteVerifier;
122189

123190
let server = ProxyServer::new(
124191
tls_cert_and_chain,
125-
address,
126-
target_address,
192+
listen_addr,
193+
target_addr,
127194
local_attestation,
128195
remote_attestation,
129196
client_auth,

0 commit comments

Comments
 (0)