Skip to content

Commit b1a2fab

Browse files
committed
Strip https:// prefix if given when specifying server address
1 parent 510b66a commit b1a2fab

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/attestation/mod.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,6 @@ impl AttestationType {
7373
}
7474
}
7575

76-
// pub fn parse_from_str(input: &str) -> Result<Self, AttestationError> {
77-
// match input {
78-
// "none" => Ok(Self::None),
79-
// "dummy" => Ok(Self::Dummy),
80-
// "azure-tdx" => Ok(Self::AzureTdx),
81-
// "qemu-tdx" => Ok(Self::QemuTdx),
82-
// "dcap-tdx" => Ok(Self::DcapTdx),
83-
// "gcp-tdx" => Ok(Self::GcpTdx),
84-
// _ => Err(AttestationError::AttestationTypeNotSupported),
85-
// }
86-
// }
87-
8876
pub fn get_quote_generator(&self) -> Result<Arc<dyn QuoteGenerator>, AttestationError> {
8977
match self {
9078
AttestationType::None => Ok(Arc::new(NoQuoteGenerator)),
@@ -122,12 +110,14 @@ pub struct AttestationVerifier {
122110
}
123111

124112
impl AttestationVerifier {
113+
/// Create an [AttestationVerifier] which will allow no remote attestation
125114
pub fn do_not_verify() -> Self {
126115
Self {
127116
accepted_measurements: Vec::new(),
128117
}
129118
}
130119

120+
/// Expect mock measurements used in tests
131121
#[cfg(test)]
132122
pub fn mock() -> Self {
133123
Self {
@@ -149,6 +139,7 @@ impl AttestationVerifier {
149139
}
150140
}
151141

142+
/// Verify an attestation, and ensure the measurements match one of our accepted measurements
152143
pub async fn verify_attestation(
153144
&self,
154145
attestation_payload: AttesationPayload,
@@ -182,6 +173,7 @@ impl AttestationVerifier {
182173
Ok(Some(measurements))
183174
}
184175

176+
/// Whether we allow no remote attestation
185177
pub fn has_remote_attestion(&self) -> bool {
186178
!self.accepted_measurements.is_empty()
187179
}

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ enum CliCommand {
3636
#[arg(short, long, default_value = "0.0.0.0:0")]
3737
listen_addr: SocketAddr,
3838
/// The hostname:port or ip:port of the proxy server (port defaults to 443)
39-
// TODO `cvm-reverse-proxy` accepts with with protocol, eg: `https://localhost:80`
4039
target_addr: String,
4140
/// The path to a PEM encoded private key for client authentication
4241
#[arg(long)]
@@ -116,6 +115,11 @@ async fn main() -> anyhow::Result<()> {
116115
client_attestation_type,
117116
server_measurements,
118117
} => {
118+
let target_addr = target_addr
119+
.strip_prefix("https://")
120+
.unwrap_or(&target_addr)
121+
.to_string();
122+
119123
let tls_cert_and_chain = if let Some(private_key) = tls_private_key_path {
120124
Some(load_tls_cert_and_key(
121125
tls_certificate_path

0 commit comments

Comments
 (0)