aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-12-07 07:56:48 -0800
committerGravatar Mark D. Roth <roth@google.com>2016-12-07 07:59:29 -0800
commitd0953408971fcc8260de83f2afce9980081f0af5 (patch)
tree2cee9cb2637d15fae68b458b29550b02c189368c /src/core/lib
parent5335cd62b68925f478248c7ff2b01a3bb31f78a9 (diff)
Allow creating security handshaker without adding it to handshake manager.
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/http/httpcli_security_connector.c4
-rw-r--r--src/core/lib/security/transport/security_connector.c31
-rw-r--r--src/core/lib/security/transport/security_handshaker.c17
-rw-r--r--src/core/lib/security/transport/security_handshaker.h13
4 files changed, 36 insertions, 29 deletions
diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c
index 7afbdeeb3f..14cdb1dab3 100644
--- a/src/core/lib/http/httpcli_security_connector.c
+++ b/src/core/lib/http/httpcli_security_connector.c
@@ -74,7 +74,9 @@ static void httpcli_ssl_add_handshakers(grpc_exec_ctx *exec_ctx,
tsi_result_to_string(result));
}
}
- grpc_security_add_handshakers(exec_ctx, handshaker, &sc->base, handshake_mgr);
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(exec_ctx, handshaker, &sc->base));
}
static void httpcli_ssl_check_peer(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c
index 33a973aa59..6431adbd61 100644
--- a/src/core/lib/security/transport/security_connector.c
+++ b/src/core/lib/security/transport/security_connector.c
@@ -43,6 +43,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
+#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
@@ -288,17 +289,21 @@ static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx,
static void fake_channel_add_handshakers(
grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc,
grpc_handshake_manager *handshake_mgr) {
- grpc_security_add_handshakers(
- exec_ctx, tsi_create_fake_handshaker(true /* is_client */), &sc->base,
- handshake_mgr);
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(
+ exec_ctx, tsi_create_fake_handshaker(true /* is_client */),
+ &sc->base));
}
-static void fake_server_add_handshakers(grpc_exec_ctx *exec_ctx,
- grpc_server_security_connector *sc,
- grpc_handshake_manager *handshake_mgr) {
- grpc_security_add_handshakers(
- exec_ctx, tsi_create_fake_handshaker(false /* is_client */), &sc->base,
- handshake_mgr);
+static void fake_server_create_handshakers(
+ grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc,
+ grpc_handshake_manager *handshake_mgr) {
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(
+ exec_ctx, tsi_create_fake_handshaker(false /* is_client */),
+ &sc->base));
}
static grpc_security_connector_vtable fake_channel_vtable = {
@@ -395,7 +400,9 @@ static void ssl_channel_add_handshakers(grpc_exec_ctx *exec_ctx,
: c->target_name,
&tsi_hs);
// Create handshakers.
- grpc_security_add_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(exec_ctx, tsi_hs, &sc->base));
}
static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
@@ -408,7 +415,9 @@ static void ssl_server_add_handshakers(grpc_exec_ctx *exec_ctx,
ssl_create_handshaker(c->handshaker_factory, false /* is_client */,
NULL /* peer_name */, &tsi_hs);
// Create handshakers.
- grpc_security_add_handshakers(exec_ctx, tsi_hs, &sc->base, handshake_mgr);
+ grpc_handshake_manager_add(
+ handshake_mgr,
+ grpc_security_handshaker_create(exec_ctx, tsi_hs, &sc->base));
}
static int ssl_host_matches_name(const tsi_peer *peer, const char *peer_name) {
diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.c
index c50d5b873c..628c747bf6 100644
--- a/src/core/lib/security/transport/security_handshaker.c
+++ b/src/core/lib/security/transport/security_handshaker.c
@@ -434,17 +434,14 @@ static grpc_handshaker *fail_handshaker_create() {
// exported functions
//
-void grpc_security_add_handshakers(grpc_exec_ctx *exec_ctx,
- tsi_handshaker *handshaker,
- grpc_security_connector *connector,
- grpc_handshake_manager *handshake_mgr) {
- // If no TSI handshaker was created, add a handshaker that always fails.
- // Otherwise, add a real security handshaker.
+grpc_handshaker *grpc_security_handshaker_create(
+ grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
+ grpc_security_connector *connector) {
+ // If no TSI handshaker was created, return a handshaker that always fails.
+ // Otherwise, return a real security handshaker.
if (handshaker == NULL) {
- grpc_handshake_manager_add(handshake_mgr, fail_handshaker_create());
+ return fail_handshaker_create();
} else {
- grpc_handshake_manager_add(
- handshake_mgr,
- security_handshaker_create(exec_ctx, handshaker, connector));
+ return security_handshaker_create(exec_ctx, handshaker, connector);
}
}
diff --git a/src/core/lib/security/transport/security_handshaker.h b/src/core/lib/security/transport/security_handshaker.h
index 745cf942b3..5ddbf4b451 100644
--- a/src/core/lib/security/transport/security_handshaker.h
+++ b/src/core/lib/security/transport/security_handshaker.h
@@ -34,14 +34,13 @@
#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H
#define GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H
-#include "src/core/lib/iomgr/endpoint.h"
+#include "src/core/lib/channel/handshaker.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/security/transport/security_connector.h"
-/// Creates any necessary security handshakers and adds them to
-/// \a handshake_mgr.
-void grpc_security_add_handshakers(grpc_exec_ctx *exec_ctx,
- tsi_handshaker *handshaker,
- grpc_security_connector *connector,
- grpc_handshake_manager *handshake_mgr);
+/// Creates a security handshaker using \a handshaker.
+grpc_handshaker *grpc_security_handshaker_create(
+ grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker,
+ grpc_security_connector *connector);
#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */