henrysun007 commented on code in PR #705: URL: https://github.com/apache/incubator-teaclave/pull/705#discussion_r1264785758
########## services/proto/src/macros.rs: ########## @@ -0,0 +1,60 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +macro_rules! include_proto { + ($package: tt) => { + include!(concat!(env!("OUT_DIR"), concat!("/", $package, ".rs"))); + }; +} + +macro_rules! impl_custom_client { + ($target: ident) => { + impl<T> $target<T> + where + T: tonic::client::GrpcService<tonic::body::BoxBody>, + T::Error: Into<tonic::codegen::StdError>, + T::ResponseBody: tonic::codegen::Body<Data = tonic::codegen::Bytes> + Send + 'static, + <T::ResponseBody as tonic::codegen::Body>::Error: Into<tonic::codegen::StdError> + Send, + { + pub fn new_with_builtin_config(inner: T) -> Self { + Self::new(inner) + .max_decoding_message_size( + teaclave_config::build::GRPC_CONFIG.max_decoding_message_size, + ) + .max_encoding_message_size( + teaclave_config::build::GRPC_CONFIG.max_encoding_message_size, + ) + } + } + }; +} + +macro_rules! impl_custom_server { + ($target: ident,$trait:ident) => { Review Comment: Whitespaces are needed after `,` and `:`. ########## attestation/src/service.rs: ########## @@ -117,21 +117,32 @@ impl EndorsedAttestationReport { } } -fn new_tls_stream(url: &url::Url) -> Result<rustls::StreamOwned<rustls::ClientSession, TcpStream>> { +fn new_tls_stream( + url: &url::Url, +) -> Result<rustls::StreamOwned<rustls::client::ClientConnection, TcpStream>> { let host_str = url .host_str() .ok_or(AttestationServiceError::InvalidAddress)?; - let dns_name = webpki::DNSNameRef::try_from_ascii_str(host_str)?; - let mut config = rustls::ClientConfig::new(); + let mut root_certs = rustls::RootCertStore::empty(); #[cfg(dcap)] - config - .root_store - .add_pem_file(&mut DCAP_ROOT_CA_CERT.to_string().as_bytes()) - .map_err(|_| AttestationServiceError::TlsError)?; - config - .root_store - .add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS); - let client = rustls::ClientSession::new(&Arc::new(config), dns_name); + { + let certs = rustls_pemfile::certs(&mut DCAP_ROOT_CA_CERT.to_string().as_bytes()) + .map_err(|_| AttestationServiceError::TlsError)?; + let (valid_count, _) = root_certs.add_parsable_certificates(&certs); + anyhow::ensure!(valid_count >= 1, "DCAP_ROOT_CA_CERT error"); + } + root_certs.add_server_trust_anchors(webpki_roots::TLS_SERVER_ROOTS.0.iter().map(|ta| { Review Comment: A more meaningful name rather than `ta` can improve the readability. ########## rpc/src/config.rs: ########## @@ -41,10 +41,48 @@ pub struct SgxTrustedTlsServerConfig { validity: std::time::Duration, } +struct AlwaysResolvesChain(Arc<rustls::sign::CertifiedKey>); Review Comment: Please state here where the code is from. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org For additional commands, e-mail: notifications-h...@teaclave.apache.org