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