Add each RDN in 'xn' to the table 't' where the NID is present in * 'nids', using key prefix 'pfx'. */
| 905 | /* Add each RDN in 'xn' to the table 't' where the NID is present in |
| 906 | * 'nids', using key prefix 'pfx'. */ |
| 907 | static void extract_dn(apr_table_t *t, apr_hash_t *nids, const char *pfx, |
| 908 | const X509_NAME *xn, apr_pool_t *p) |
| 909 | { |
| 910 | const X509_NAME_ENTRY *xsne; |
| 911 | apr_hash_t *count; |
| 912 | int i, nid; |
| 913 | |
| 914 | /* Hash of (int) NID -> (int *) counter to count each time an RDN |
| 915 | * with the given NID has been seen. */ |
| 916 | count = apr_hash_make(p); |
| 917 | |
| 918 | /* For each RDN... */ |
| 919 | for (i = 0; i < X509_NAME_entry_count(xn); i++) { |
| 920 | const char *tag; |
| 921 | xsne = X509_NAME_get_entry(xn, i); |
| 922 | |
| 923 | /* Retrieve the nid, and check whether this is one of the nids |
| 924 | * which are to be extracted. */ |
| 925 | nid = OBJ_obj2nid(X509_NAME_ENTRY_get_object(xsne)); |
| 926 | |
| 927 | tag = apr_hash_get(nids, &nid, sizeof nid); |
| 928 | if (tag) { |
| 929 | const char *key; |
| 930 | int *dup; |
| 931 | char *value; |
| 932 | |
| 933 | /* Check whether a variable with this nid was already |
| 934 | * been used; if so, use the foo_N=bar syntax. */ |
| 935 | dup = apr_hash_get(count, &nid, sizeof nid); |
| 936 | if (dup) { |
| 937 | key = apr_psprintf(p, "%s%s_%d", pfx, tag, ++(*dup)); |
| 938 | } |
| 939 | else { |
| 940 | /* Otherwise, use the plain foo=bar syntax. */ |
| 941 | dup = apr_pcalloc(p, sizeof *dup); |
| 942 | apr_hash_set(count, &nid, sizeof nid, dup); |
| 943 | key = apr_pstrcat(p, pfx, tag, NULL); |
| 944 | } |
| 945 | value = modssl_X509_NAME_ENTRY_to_string(p, xsne, 0); |
| 946 | apr_table_setn(t, key, value); |
| 947 | } |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | void modssl_var_extract_dns(apr_table_t *t, SSL *ssl, apr_pool_t *p) |
| 952 | { |
no test coverage detected