Merge pull request #1270 from jboeuf/server_security_context_factory

Refactoring of server context creation (incremental improvement).
pull/1277/head
Yang Gao 10 years ago
commit 7b3b058b57
  1. 16
      src/core/security/factories.c
  2. 7
      src/core/security/security_context.h
  3. 11
      src/core/security/server_secure_chttp2.c

@ -50,3 +50,19 @@ grpc_channel *grpc_secure_channel_create(grpc_credentials *creds,
return grpc_secure_channel_create_with_factories( return grpc_secure_channel_create_with_factories(
factories, GPR_ARRAY_SIZE(factories), creds, target, args); factories, GPR_ARRAY_SIZE(factories), creds, target, args);
} }
grpc_security_status grpc_server_security_context_create(
grpc_server_credentials *creds, grpc_security_context **ctx) {
grpc_security_status status = GRPC_SECURITY_ERROR;
*ctx = NULL;
if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL) == 0) {
status = grpc_ssl_server_security_context_create(
grpc_ssl_server_credentials_get_config(creds), ctx);
} else if (strcmp(creds->type,
GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY) == 0) {
*ctx = grpc_fake_server_security_context_create();
status = GRPC_SECURITY_OK;
}
return status;
}

@ -206,10 +206,9 @@ grpc_channel *grpc_secure_channel_create_with_factories(
const grpc_secure_channel_factory *factories, size_t num_factories, const grpc_secure_channel_factory *factories, size_t num_factories,
grpc_credentials *creds, const char *target, const grpc_channel_args *args); grpc_credentials *creds, const char *target, const grpc_channel_args *args);
/* Secure server creation. */ /* Secure server context creation. */
grpc_server *grpc_secure_server_create_internal(grpc_completion_queue *cq, grpc_security_status grpc_server_security_context_create(
const grpc_channel_args *args, grpc_server_credentials *creds, grpc_security_context **ctx);
grpc_security_context *ctx);
#endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */ #endif /* GRPC_INTERNAL_CORE_SECURITY_SECURITY_CONTEXT_H */

@ -141,16 +141,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
/* create security context */ /* create security context */
if (creds == NULL) goto error; if (creds == NULL) goto error;
status = grpc_server_security_context_create(creds, &ctx);
if (strcmp(creds->type, GRPC_CREDENTIALS_TYPE_SSL) == 0) {
status = grpc_ssl_server_security_context_create(
grpc_ssl_server_credentials_get_config(creds), &ctx);
} else if (strcmp(creds->type,
GRPC_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY) == 0) {
ctx = grpc_fake_server_security_context_create();
status = GRPC_SECURITY_OK;
}
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Unable to create secure server with credentials of type %s.", "Unable to create secure server with credentials of type %s.",

Loading…
Cancel
Save