48a49,50
> static nxt_conf_value_t *nxt_cert_alt_names_details(nxt_mp_t *mp,
> STACK_OF(GENERAL_NAME) *alt_names);
657d658
< GENERAL_NAME *name;
724,725c725
< count = sk_GENERAL_NAME_num(alt_names);
< n = 0;
---
> names = nxt_cert_alt_names_details(mp, alt_names);
727,728c727
< for (i = 0; i != count; i++) {
< name = sk_GENERAL_NAME_value(alt_names, i);
---
> sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free);
730,737d728
< if (name->type != GEN_DNS) {
< continue;
< }
<
< n++;
< }
<
< names = nxt_conf_create_array(mp, n);
739c730
< goto fail;
---
> return NULL;
742,763d732
< for (n = 0, i = 0; n != count; n++) {
< name = sk_GENERAL_NAME_value(alt_names, n);
<
< if (name->type != GEN_DNS) {
< continue;
< }
<
< str.length = ASN1_STRING_length(name->d.dNSName);
< #if OPENSSL_VERSION_NUMBER > 0x10100000L
< str.start = (u_char *) ASN1_STRING_get0_data(name->d.dNSName);
< #else
< str.start = ASN1_STRING_data(name->d.dNSName);
< #endif
<
< ret = nxt_conf_set_element_string_dup(names, mp, i++, &str);
< if (nxt_slow_path(ret != NXT_OK)) {
< goto fail;
< }
< }
<
< sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free);
<
778a748,798
> static nxt_conf_value_t *
> nxt_cert_alt_names_details(nxt_mp_t *mp, STACK_OF(GENERAL_NAME) *alt_names)
> {
> nxt_str_t str;
> nxt_int_t ret;
> nxt_uint_t i, n, count;
> GENERAL_NAME *name;
> nxt_conf_value_t *array;
>
> count = sk_GENERAL_NAME_num(alt_names);
> n = 0;
>
> for (i = 0; i != count; i++) {
> name = sk_GENERAL_NAME_value(alt_names, i);
>
> if (name->type != GEN_DNS) {
> continue;
> }
>
> n++;
> }
>
> array = nxt_conf_create_array(mp, n);
> if (nxt_slow_path(array == NULL)) {
> return NULL;
> }
>
> for (n = 0, i = 0; n != count; n++) {
> name = sk_GENERAL_NAME_value(alt_names, n);
>
> if (name->type != GEN_DNS) {
> continue;
> }
>
> str.length = ASN1_STRING_length(name->d.dNSName);
> #if OPENSSL_VERSION_NUMBER > 0x10100000L
> str.start = (u_char *) ASN1_STRING_get0_data(name->d.dNSName);
> #else
> str.start = ASN1_STRING_data(name->d.dNSName);
> #endif
>
> ret = nxt_conf_set_element_string_dup(array, mp, i++, &str);
> if (nxt_slow_path(ret != NXT_OK)) {
> return NULL;
> }
> }
>
> return array;
> }
>
>