aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/httpcli/httpcli_security_connector.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/httpcli/httpcli_security_connector.c')
-rw-r--r--src/core/httpcli/httpcli_security_connector.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/core/httpcli/httpcli_security_connector.c b/src/core/httpcli/httpcli_security_connector.c
index 7887f9d530..86f34db1d0 100644
--- a/src/core/httpcli/httpcli_security_connector.c
+++ b/src/core/httpcli/httpcli_security_connector.c
@@ -35,7 +35,7 @@
#include <string.h>
-#include "src/core/security/secure_transport_setup.h"
+#include "src/core/security/handshake.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -58,20 +58,27 @@ static void httpcli_ssl_destroy(grpc_security_connector *sc) {
gpr_free(sc);
}
-static grpc_security_status httpcli_ssl_create_handshaker(
- grpc_security_connector *sc, tsi_handshaker **handshaker) {
+static void httpcli_ssl_do_handshake(
+ grpc_security_connector *sc, grpc_endpoint *nonsecure_endpoint,
+ grpc_security_handshake_done_cb cb, void *user_data) {
grpc_httpcli_ssl_channel_security_connector *c =
(grpc_httpcli_ssl_channel_security_connector *)sc;
tsi_result result = TSI_OK;
- if (c->handshaker_factory == NULL) return GRPC_SECURITY_ERROR;
+ tsi_handshaker *handshaker;
+ if (c->handshaker_factory == NULL) {
+ cb(user_data, GRPC_SECURITY_ERROR, nonsecure_endpoint, NULL);
+ return;
+ }
result = tsi_ssl_handshaker_factory_create_handshaker(
- c->handshaker_factory, c->secure_peer_name, handshaker);
+ c->handshaker_factory, c->secure_peer_name, &handshaker);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker creation failed with error %s.",
tsi_result_to_string(result));
- return GRPC_SECURITY_ERROR;
+ cb(user_data, GRPC_SECURITY_ERROR, nonsecure_endpoint, NULL);
+ } else {
+ grpc_do_security_handshake(handshaker, sc, nonsecure_endpoint, cb,
+ user_data);
}
- return GRPC_SECURITY_OK;
}
static grpc_security_status httpcli_ssl_check_peer(grpc_security_connector *sc,
@@ -94,7 +101,7 @@ static grpc_security_status httpcli_ssl_check_peer(grpc_security_connector *sc,
}
static grpc_security_connector_vtable httpcli_ssl_vtable = {
- httpcli_ssl_destroy, httpcli_ssl_create_handshaker, httpcli_ssl_check_peer};
+ httpcli_ssl_destroy, httpcli_ssl_do_handshake, httpcli_ssl_check_peer};
static grpc_security_status httpcli_ssl_channel_security_connector_create(
const unsigned char *pem_root_certs, size_t pem_root_certs_size,
@@ -169,8 +176,8 @@ static void ssl_handshake(void *arg, grpc_endpoint *tcp, const char *host,
GPR_ASSERT(httpcli_ssl_channel_security_connector_create(
pem_root_certs, pem_root_certs_size, host, &sc) ==
GRPC_SECURITY_OK);
- grpc_setup_secure_transport(&sc->base, tcp, on_secure_transport_setup_done,
- c);
+ grpc_security_connector_do_handshake(&sc->base, tcp,
+ on_secure_transport_setup_done, c);
GRPC_SECURITY_CONNECTOR_UNREF(&sc->base, "httpcli");
}