aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/security
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-17 14:28:56 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-17 14:28:56 -0700
commit0596621ec2b8c79b39fdffa12132b445eea8e49f (patch)
tree1c666cab69dcd23ea54bbce7d79923321760aa8b /src/core/security
parent83b826aef5631f797f912a5c7570aa1f6b76cabc (diff)
parent669df902c997cc66abfa7aad21c5abbcc6344ea4 (diff)
Merge github.com:grpc/grpc into we-dont-need-no-backup
Diffstat (limited to 'src/core/security')
-rw-r--r--src/core/security/security_connector.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c
index dbd79c5b22..61cb20f6b9 100644
--- a/src/core/security/security_connector.c
+++ b/src/core/security/security_connector.c
@@ -81,6 +81,24 @@ static const char *ssl_cipher_suites(void) {
/* -- Common methods. -- */
+/* Returns the first property with that name. */
+static const tsi_peer_property *tsi_peer_get_property_by_name(
+ const tsi_peer *peer, const char *name) {
+ size_t i;
+ if (peer == NULL) return NULL;
+ for (i = 0; i < peer->property_count; i++) {
+ const tsi_peer_property* property = &peer->properties[i];
+ if (name == NULL && property->name == NULL) {
+ return property;
+ }
+ if (name != NULL && property->name != NULL &&
+ strcmp(property->name, name) == 0) {
+ return property;
+ }
+ }
+ return NULL;
+}
+
grpc_security_status grpc_security_connector_create_handshaker(
grpc_security_connector *sc, tsi_handshaker **handshaker) {
if (sc == NULL || handshaker == NULL) return GRPC_SECURITY_ERROR;
@@ -212,13 +230,8 @@ static grpc_security_status fake_check_peer(grpc_security_connector *sc,
status = GRPC_SECURITY_ERROR;
goto end;
}
- if (peer.properties[0].type != TSI_PEER_PROPERTY_TYPE_STRING) {
- gpr_log(GPR_ERROR, "Invalid type of cert type property.");
- status = GRPC_SECURITY_ERROR;
- goto end;
- }
- if (strncmp(peer.properties[0].value.string.data, TSI_FAKE_CERTIFICATE_TYPE,
- peer.properties[0].value.string.length)) {
+ if (strncmp(peer.properties[0].value.data, TSI_FAKE_CERTIFICATE_TYPE,
+ peer.properties[0].value.length)) {
gpr_log(GPR_ERROR, "Invalid value for cert type property.");
status = GRPC_SECURITY_ERROR;
goto end;
@@ -365,12 +378,7 @@ static grpc_security_status ssl_check_peer(const char *peer_name,
gpr_log(GPR_ERROR, "Missing selected ALPN property.");
return GRPC_SECURITY_ERROR;
}
- if (p->type != TSI_PEER_PROPERTY_TYPE_STRING) {
- gpr_log(GPR_ERROR, "Invalid selected ALPN property.");
- return GRPC_SECURITY_ERROR;
- }
- if (!grpc_chttp2_is_alpn_version_supported(p->value.string.data,
- p->value.string.length)) {
+ if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
gpr_log(GPR_ERROR, "Invalid ALPN value.");
return GRPC_SECURITY_ERROR;
}