|
|
|
@ -344,24 +344,18 @@ static tsi_result add_subject_alt_names_properties_to_peer( |
|
|
|
|
size_t subject_alt_name_count) { |
|
|
|
|
size_t i; |
|
|
|
|
tsi_result result = TSI_OK; |
|
|
|
|
|
|
|
|
|
/* Reset for DNS entries filtering. */ |
|
|
|
|
peer->property_count -= subject_alt_name_count; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < subject_alt_name_count; i++) { |
|
|
|
|
GENERAL_NAME* subject_alt_name = |
|
|
|
|
sk_GENERAL_NAME_value(subject_alt_names, TSI_SIZE_AS_SIZE(i)); |
|
|
|
|
if (subject_alt_name->type == GEN_DNS || |
|
|
|
|
subject_alt_name->type == GEN_EMAIL || |
|
|
|
|
subject_alt_name->type == GEN_URI) { |
|
|
|
|
/* Filter out the non-dns entries names. */ |
|
|
|
|
if (subject_alt_name->type == GEN_DNS) { |
|
|
|
|
unsigned char* name = nullptr; |
|
|
|
|
int name_size; |
|
|
|
|
if (subject_alt_name->type == GEN_DNS) { |
|
|
|
|
name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName); |
|
|
|
|
} else if (subject_alt_name->type == GEN_EMAIL) { |
|
|
|
|
name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.rfc822Name); |
|
|
|
|
} else { |
|
|
|
|
name_size = ASN1_STRING_to_UTF8( |
|
|
|
|
&name, subject_alt_name->d.uniformResourceIdentifier); |
|
|
|
|
} |
|
|
|
|
name_size = ASN1_STRING_to_UTF8(&name, subject_alt_name->d.dNSName); |
|
|
|
|
if (name_size < 0) { |
|
|
|
|
gpr_log(GPR_ERROR, "Could not get utf8 from asn1 string."); |
|
|
|
|
result = TSI_INTERNAL_ERROR; |
|
|
|
@ -375,6 +369,7 @@ static tsi_result add_subject_alt_names_properties_to_peer( |
|
|
|
|
} else if (subject_alt_name->type == GEN_IPADD) { |
|
|
|
|
char ntop_buf[INET6_ADDRSTRLEN]; |
|
|
|
|
int af; |
|
|
|
|
|
|
|
|
|
if (subject_alt_name->d.iPAddress->length == 4) { |
|
|
|
|
af = AF_INET; |
|
|
|
|
} else if (subject_alt_name->d.iPAddress->length == 16) { |
|
|
|
@ -391,6 +386,7 @@ static tsi_result add_subject_alt_names_properties_to_peer( |
|
|
|
|
result = TSI_INTERNAL_ERROR; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
result = tsi_construct_string_peer_property_from_cstring( |
|
|
|
|
TSI_X509_SUBJECT_ALTERNATIVE_NAME_PEER_PROPERTY, name, |
|
|
|
|
&peer->properties[peer->property_count++]); |
|
|
|
|