diff options
author | Julien Boeuf <jboeuf@google.com> | 2015-04-17 14:38:48 -0700 |
---|---|---|
committer | Julien Boeuf <jboeuf@google.com> | 2015-04-17 23:41:46 -0700 |
commit | 7d1d9ca7faf6e5cd37df572ab98ff500c07297b9 (patch) | |
tree | bdeaa9100ae91aeb9a8ec4a83f7a25b7348ad043 /src/core/httpcli | |
parent | 4f558f536c1bfe523e0dd0250420785d54dcc326 (diff) |
Refactoring of core security to remove the factories.
- Renamed security_context -> security_connector.
- Credentials are now responsible for creating their own connectors.
Diffstat (limited to 'src/core/httpcli')
-rw-r--r-- | src/core/httpcli/httpcli.c | 13 | ||||
-rw-r--r-- | src/core/httpcli/httpcli_security_connector.c (renamed from src/core/httpcli/httpcli_security_context.c) | 42 | ||||
-rw-r--r-- | src/core/httpcli/httpcli_security_connector.h (renamed from src/core/httpcli/httpcli_security_context.h) | 12 |
3 files changed, 33 insertions, 34 deletions
diff --git a/src/core/httpcli/httpcli.c b/src/core/httpcli/httpcli.c index d2cf09a8df..fe7ea6a86b 100644 --- a/src/core/httpcli/httpcli.c +++ b/src/core/httpcli/httpcli.c @@ -40,9 +40,8 @@ #include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/tcp_client.h" #include "src/core/httpcli/format_request.h" -#include "src/core/httpcli/httpcli_security_context.h" +#include "src/core/httpcli/httpcli_security_connector.h" #include "src/core/httpcli/parser.h" -#include "src/core/security/security_context.h" #include "src/core/security/secure_transport_setup.h" #include "src/core/support/string.h" #include <grpc/support/alloc.h> @@ -180,7 +179,7 @@ static void on_connected(void *arg, grpc_endpoint *tcp) { } req->ep = tcp; if (req->use_ssl) { - grpc_channel_security_context *ctx = NULL; + grpc_channel_security_connector *sc = NULL; const unsigned char *pem_root_certs = NULL; size_t pem_root_certs_size = grpc_get_default_ssl_roots(&pem_root_certs); if (pem_root_certs == NULL || pem_root_certs_size == 0) { @@ -188,12 +187,12 @@ static void on_connected(void *arg, grpc_endpoint *tcp) { finish(req, 0); return; } - GPR_ASSERT(grpc_httpcli_ssl_channel_security_context_create( - pem_root_certs, pem_root_certs_size, req->host, &ctx) == + GPR_ASSERT(grpc_httpcli_ssl_channel_security_connector_create( + pem_root_certs, pem_root_certs_size, req->host, &sc) == GRPC_SECURITY_OK); - grpc_setup_secure_transport(&ctx->base, tcp, on_secure_transport_setup_done, + grpc_setup_secure_transport(&sc->base, tcp, on_secure_transport_setup_done, req); - grpc_security_context_unref(&ctx->base); + grpc_security_connector_unref(&sc->base); } else { start_write(req); } diff --git a/src/core/httpcli/httpcli_security_context.c b/src/core/httpcli/httpcli_security_connector.c index e97752bbe1..6eed5eaf12 100644 --- a/src/core/httpcli/httpcli_security_context.c +++ b/src/core/httpcli/httpcli_security_connector.c @@ -31,7 +31,7 @@ * */ -#include "src/core/httpcli/httpcli_security_context.h" +#include "src/core/httpcli/httpcli_security_connector.h" #include <string.h> @@ -42,25 +42,25 @@ #include "src/core/tsi/ssl_transport_security.h" typedef struct { - grpc_channel_security_context base; + grpc_channel_security_connector base; tsi_ssl_handshaker_factory *handshaker_factory; char *secure_peer_name; -} grpc_httpcli_ssl_channel_security_context; +} grpc_httpcli_ssl_channel_security_connector; -static void httpcli_ssl_destroy(grpc_security_context *ctx) { - grpc_httpcli_ssl_channel_security_context *c = - (grpc_httpcli_ssl_channel_security_context *)ctx; +static void httpcli_ssl_destroy(grpc_security_connector *sc) { + grpc_httpcli_ssl_channel_security_connector *c = + (grpc_httpcli_ssl_channel_security_connector *)sc; if (c->handshaker_factory != NULL) { tsi_ssl_handshaker_factory_destroy(c->handshaker_factory); } if (c->secure_peer_name != NULL) gpr_free(c->secure_peer_name); - gpr_free(ctx); + gpr_free(sc); } static grpc_security_status httpcli_ssl_create_handshaker( - grpc_security_context *ctx, tsi_handshaker **handshaker) { - grpc_httpcli_ssl_channel_security_context *c = - (grpc_httpcli_ssl_channel_security_context *)ctx; + grpc_security_connector *sc, tsi_handshaker **handshaker) { + 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; result = tsi_ssl_handshaker_factory_create_handshaker( @@ -73,12 +73,12 @@ static grpc_security_status httpcli_ssl_create_handshaker( return GRPC_SECURITY_OK; } -static grpc_security_status httpcli_ssl_check_peer(grpc_security_context *ctx, +static grpc_security_status httpcli_ssl_check_peer(grpc_security_connector *sc, tsi_peer peer, grpc_security_check_cb cb, void *user_data) { - grpc_httpcli_ssl_channel_security_context *c = - (grpc_httpcli_ssl_channel_security_context *)ctx; + grpc_httpcli_ssl_channel_security_connector *c = + (grpc_httpcli_ssl_channel_security_connector *)sc; grpc_security_status status = GRPC_SECURITY_OK; /* Check the peer name. */ @@ -92,14 +92,14 @@ static grpc_security_status httpcli_ssl_check_peer(grpc_security_context *ctx, return status; } -static grpc_security_context_vtable httpcli_ssl_vtable = { +static grpc_security_connector_vtable httpcli_ssl_vtable = { httpcli_ssl_destroy, httpcli_ssl_create_handshaker, httpcli_ssl_check_peer}; -grpc_security_status grpc_httpcli_ssl_channel_security_context_create( +grpc_security_status grpc_httpcli_ssl_channel_security_connector_create( const unsigned char *pem_root_certs, size_t pem_root_certs_size, - const char *secure_peer_name, grpc_channel_security_context **ctx) { + const char *secure_peer_name, grpc_channel_security_connector **sc) { tsi_result result = TSI_OK; - grpc_httpcli_ssl_channel_security_context *c; + grpc_httpcli_ssl_channel_security_connector *c; if (secure_peer_name != NULL && pem_root_certs == NULL) { gpr_log(GPR_ERROR, @@ -107,8 +107,8 @@ grpc_security_status grpc_httpcli_ssl_channel_security_context_create( return GRPC_SECURITY_ERROR; } - c = gpr_malloc(sizeof(grpc_httpcli_ssl_channel_security_context)); - memset(c, 0, sizeof(grpc_httpcli_ssl_channel_security_context)); + c = gpr_malloc(sizeof(grpc_httpcli_ssl_channel_security_connector)); + memset(c, 0, sizeof(grpc_httpcli_ssl_channel_security_connector)); gpr_ref_init(&c->base.base.refcount, 1); c->base.base.is_client_side = 1; @@ -123,9 +123,9 @@ grpc_security_status grpc_httpcli_ssl_channel_security_context_create( gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.", tsi_result_to_string(result)); httpcli_ssl_destroy(&c->base.base); - *ctx = NULL; + *sc = NULL; return GRPC_SECURITY_ERROR; } - *ctx = &c->base; + *sc = &c->base; return GRPC_SECURITY_OK; } diff --git a/src/core/httpcli/httpcli_security_context.h b/src/core/httpcli/httpcli_security_connector.h index a776828a69..c50f25905e 100644 --- a/src/core/httpcli/httpcli_security_context.h +++ b/src/core/httpcli/httpcli_security_connector.h @@ -31,13 +31,13 @@ * */ -#ifndef GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H -#define GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H +#ifndef GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONNECTOR_H +#define GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONNECTOR_H -#include "src/core/security/security_context.h" +#include "src/core/security/security_connector.h" -grpc_security_status grpc_httpcli_ssl_channel_security_context_create( +grpc_security_status grpc_httpcli_ssl_channel_security_connector_create( const unsigned char *pem_root_certs, size_t pem_root_certs_size, - const char *secure_peer_name, grpc_channel_security_context **ctx); + const char *secure_peer_name, grpc_channel_security_connector **sc); -#endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONTEXT_H */ +#endif /* GRPC_INTERNAL_CORE_HTTPCLI_HTTPCLI_SECURITY_CONNECTOR_H */ |