From 2b63879becd19f57a5c31abdf1ea2163427e0719 Mon Sep 17 00:00:00 2001 From: erm-g Date: Sun, 20 Aug 2023 05:57:26 +0000 Subject: [PATCH] Automated change: Fix sanity tests --- .../alts/handshaker/alts_tsi_handshaker.cc | 3 ++- src/core/tsi/fake_transport_security.cc | 3 ++- src/core/tsi/local_transport_security.cc | 4 ++-- src/core/tsi/ssl_transport_security.cc | 21 ++++++++++--------- src/core/tsi/transport_security.cc | 4 ++-- src/core/tsi/transport_security.h | 3 ++- src/core/tsi/transport_security_interface.h | 9 ++++---- 7 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc index f85c07f68a555..c0aa0224dfd85 100644 --- a/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +++ b/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc @@ -203,7 +203,8 @@ static tsi_result handshaker_result_extract_local_peer( ok = tsi_construct_string_peer_property( TSI_ALTS_CONTEXT, reinterpret_cast(GRPC_SLICE_START_PTR(result->serialized_context)), - GRPC_SLICE_LENGTH(result->serialized_context), &local_peer->properties[index]); + GRPC_SLICE_LENGTH(result->serialized_context), + &local_peer->properties[index]); if (ok != TSI_OK) { tsi_peer_destruct(local_peer); gpr_log(GPR_ERROR, "Failed to set tsi peer property"); diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc index 14232803bb9f4..76df7607a42ff 100644 --- a/src/core/tsi/fake_transport_security.cc +++ b/src/core/tsi/fake_transport_security.cc @@ -556,7 +556,8 @@ static tsi_result fake_handshaker_result_extract_local_peer( if (result != TSI_OK) tsi_peer_destruct(local_peer); result = tsi_construct_string_peer_property_from_cstring( TSI_SECURITY_LEVEL_PEER_PROPERTY, - tsi_security_level_to_string(TSI_SECURITY_NONE), &local_peer->properties[1]); + tsi_security_level_to_string(TSI_SECURITY_NONE), + &local_peer->properties[1]); if (result != TSI_OK) tsi_peer_destruct(local_peer); return result; } diff --git a/src/core/tsi/local_transport_security.cc b/src/core/tsi/local_transport_security.cc index 0c748dac63845..c9c08313eddc9 100644 --- a/src/core/tsi/local_transport_security.cc +++ b/src/core/tsi/local_transport_security.cc @@ -58,8 +58,8 @@ tsi_result handshaker_result_extract_peer(const tsi_handshaker_result* /*self*/, return TSI_OK; } -tsi_result handshaker_result_extract_local_peer(const tsi_handshaker_result* /*self*/, - tsi_peer* /*peer*/) { +tsi_result handshaker_result_extract_local_peer( + const tsi_handshaker_result* /*self*/, tsi_peer* /*peer*/) { return TSI_OK; } diff --git a/src/core/tsi/ssl_transport_security.cc b/src/core/tsi/ssl_transport_security.cc index 96cf6010b088a..3d06aa863946b 100644 --- a/src/core/tsi/ssl_transport_security.cc +++ b/src/core/tsi/ssl_transport_security.cc @@ -22,6 +22,7 @@ #include #include + #include // TODO(jboeuf): refactor inet_ntop into a portability header. @@ -1262,7 +1263,7 @@ static tsi_result ssl_handshaker_result_extract_local_peer( unsigned int alpn_selected_len; const tsi_ssl_handshaker_result* impl = reinterpret_cast(self); - X509 *local_cert = SSL_get_certificate(impl->ssl); + X509* local_cert = SSL_get_certificate(impl->ssl); if (local_cert != nullptr) { result = peer_from_x509(local_cert, 1, local_peer); X509_free(local_cert); @@ -1446,14 +1447,14 @@ static tsi_result ssl_handshaker_get_result(tsi_ssl_handshaker* impl) { return impl->result; } -void print_cert_info(X509 *cert) { - BIO *bio = BIO_new_fp(stdout, BIO_NOCLOSE); - X509_NAME_print_ex(bio, X509_get_subject_name(cert), 0, XN_FLAG_ONELINE); - BIO_puts(bio, "\n"); - X509_NAME_print_ex(bio, X509_get_issuer_name(cert), 0, XN_FLAG_ONELINE); - BIO_puts(bio, "\n"); +void print_cert_info(X509* cert) { + BIO* bio = BIO_new_fp(stdout, BIO_NOCLOSE); + X509_NAME_print_ex(bio, X509_get_subject_name(cert), 0, XN_FLAG_ONELINE); + BIO_puts(bio, "\n"); + X509_NAME_print_ex(bio, X509_get_issuer_name(cert), 0, XN_FLAG_ONELINE); + BIO_puts(bio, "\n"); - BIO_free(bio); + BIO_free(bio); } static tsi_result ssl_handshaker_do_handshake(tsi_ssl_handshaker* impl, @@ -1467,9 +1468,9 @@ static tsi_result ssl_handshaker_do_handshake(tsi_ssl_handshaker* impl, int ssl_result = SSL_do_handshake(impl->ssl); ssl_result = SSL_get_error(impl->ssl, ssl_result); printf("***** Handshake successful p\n"); - X509 *server_cert = SSL_get_certificate(impl->ssl); + X509* server_cert = SSL_get_certificate(impl->ssl); if (server_cert) { - X509_print_fp(stderr, server_cert); + X509_print_fp(stderr, server_cert); } switch (ssl_result) { case SSL_ERROR_WANT_READ: diff --git a/src/core/tsi/transport_security.cc b/src/core/tsi/transport_security.cc index bb9cdf3a01932..ca94e32138d0b 100644 --- a/src/core/tsi/transport_security.cc +++ b/src/core/tsi/transport_security.cc @@ -263,8 +263,8 @@ tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result* self, return self->vtable->extract_peer(self, peer); } -tsi_result tsi_handshaker_result_extract_local_peer(const tsi_handshaker_result* self, - tsi_peer* local_peer) { +tsi_result tsi_handshaker_result_extract_local_peer( + const tsi_handshaker_result* self, tsi_peer* local_peer) { if (self == nullptr || self->vtable == nullptr || local_peer == nullptr) { return TSI_INVALID_ARGUMENT; } diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h index eeb72335726b3..84175b557a9f3 100644 --- a/src/core/tsi/transport_security.h +++ b/src/core/tsi/transport_security.h @@ -100,7 +100,8 @@ struct tsi_handshaker { // struct tsi_handshaker_result_vtable { tsi_result (*extract_peer)(const tsi_handshaker_result* self, tsi_peer* peer); - tsi_result (*extract_local_peer)(const tsi_handshaker_result* self, tsi_peer* local_peer); + tsi_result (*extract_local_peer)(const tsi_handshaker_result* self, + tsi_peer* local_peer); tsi_result (*get_frame_protector_type)( const tsi_handshaker_result* self, tsi_frame_protector_type* frame_protector_type); diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h index a251194bd19d6..5846cc9868726 100644 --- a/src/core/tsi/transport_security_interface.h +++ b/src/core/tsi/transport_security_interface.h @@ -258,11 +258,10 @@ typedef struct tsi_handshaker_result tsi_handshaker_result; tsi_result tsi_handshaker_result_extract_peer(const tsi_handshaker_result* self, tsi_peer* peer); -// This method extracts tsi local peer. It returns TSI_OK assuming there is no fatal -// error. -// The caller is responsible for destructing the local peer. -tsi_result tsi_handshaker_result_extract_local_peer(const tsi_handshaker_result* self, - tsi_peer* local_peer); +// This method extracts tsi local peer. It returns TSI_OK assuming there is no +// fatal error. The caller is responsible for destructing the local peer. +tsi_result tsi_handshaker_result_extract_local_peer( + const tsi_handshaker_result* self, tsi_peer* local_peer); // This method indicates what type of frame protector is provided by the // TSI implementation.