Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated fix for refs/heads/AuthContextLocalPeer #2

Open
wants to merge 1 commit into
base: AuthContextLocalPeer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ static tsi_result handshaker_result_extract_local_peer(
ok = tsi_construct_string_peer_property(
TSI_ALTS_CONTEXT,
reinterpret_cast<char*>(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");
Expand Down
3 changes: 2 additions & 1 deletion src/core/tsi/fake_transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/tsi/local_transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
21 changes: 11 additions & 10 deletions src/core/tsi/ssl_transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <limits.h>
#include <string.h>

#include <memory>

// TODO(jboeuf): refactor inet_ntop into a portability header.
Expand Down Expand Up @@ -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<const tsi_ssl_handshaker_result*>(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);
Expand Down Expand Up @@ -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,
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/core/tsi/transport_security.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/core/tsi/transport_security.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions src/core/tsi/transport_security_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down